Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

SQL Date Between Problem

 
   Database Help (Home) -> Visual Basic -> DAO RSS
Next:  Data Source - Data Report Designer  
Author Message
Jordan Sopher

External


Since: Sep 25, 2003
Posts: 1



(Msg. 1) Posted: Thu Sep 25, 2003 7:13 am
Post subject: SQL Date Between Problem
Archived from groups: microsoft>public>vb>database>dao (more info?)

Hello...

I need some help with my SQL syntax, so it account for
all international date formats. For example, if you set
your region to Germany (germany), the short date format
is DD.MM.YYYY. This will invoke the 3075 run-time
error. Here's my queries:

Private Sub Command1_Click()
strTemp1 = MonthView1(0).month & "/" & MonthView1
(0).day & "/" & MonthView1(0).year
strTemp2 = MonthView1(1).month & "/" & MonthView1
(1).day & "/" & MonthView1(1).year

frdate = DateValue(Format(strTemp1, "Short Date"))
todate = DateValue(Format(strTemp2, "Short Date"))

Call GenerateHTML(cmbList.Text, frdate, todate)
End Sub


Private Sub GenerateHTML(strItem As String, beginDate As
Date, endDate As Date)
If strItem = "= ALL =" Then
sSql = "SELECT Title, SUM(mCount) AS SumCount
FROM Reports WHERE mDate BETWEEN #" & beginDate & "# AND
#" & _
endDate & "# GROUP BY Title"
Else
sSql = "SELECT Title, SUM(mCount) AS SumCount
FROM Reports WHERE mDate BETWEEN #" & beginDate & "# AND
#" & _
endDate & "# AND Title LIKE '" &
strItem & "' GROUP BY Title"
End If
End Sub


any help would be appreciated.

 >> Stay informed about: SQL Date Between Problem 
Back to top
Login to vote
DIOS

External


Since: Sep 12, 2003
Posts: 22



(Msg. 2) Posted: Fri Sep 26, 2003 12:58 am
Post subject: Re: SQL Date Between Problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

what about using CDate(strTemp1)

AGP


--

**********************************************************************
Unpak my email address before sending me personal email
**********************************************************************

"Jordan Sopher" <jordan.TakeThisOut@eyemaginations.com> wrote in message
news:004001c3836f$3c34af00$a101280a@phx.gbl...
> Hello...
>
> I need some help with my SQL syntax, so it account for
> all international date formats. For example, if you set
> your region to Germany (germany), the short date format
> is DD.MM.YYYY. This will invoke the 3075 run-time
> error. Here's my queries:
>
> Private Sub Command1_Click()
> strTemp1 = MonthView1(0).month & "/" & MonthView1
> (0).day & "/" & MonthView1(0).year
> strTemp2 = MonthView1(1).month & "/" & MonthView1
> (1).day & "/" & MonthView1(1).year
>
> frdate = DateValue(Format(strTemp1, "Short Date"))
> todate = DateValue(Format(strTemp2, "Short Date"))
>
> Call GenerateHTML(cmbList.Text, frdate, todate)
> End Sub
>
>
> Private Sub GenerateHTML(strItem As String, beginDate As
> Date, endDate As Date)
> If strItem = "= ALL =" Then
> sSql = "SELECT Title, SUM(mCount) AS SumCount
> FROM Reports WHERE mDate BETWEEN #" & beginDate & "# AND
> #" & _
> endDate & "# GROUP BY Title"
> Else
> sSql = "SELECT Title, SUM(mCount) AS SumCount
> FROM Reports WHERE mDate BETWEEN #" & beginDate & "# AND
> #" & _
> endDate & "# AND Title LIKE '" &
> strItem & "' GROUP BY Title"
> End If
> End Sub
>
>
> any help would be appreciated.

 >> Stay informed about: SQL Date Between Problem 
Back to top
Login to vote
Michael Cole

External


Since: Sep 18, 2003
Posts: 3



(Msg. 3) Posted: Fri Sep 26, 2003 5:14 pm
Post subject: Re: SQL Date Between Problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Jordan Sopher wrote:
> Hello...
>
> I need some help with my SQL syntax, so it account for
> all international date formats. For example, if you set

SQL fornat for which database? They can differ. Here are some...

Public Function SQLFormatDate(ByVal ActualDate As Date, ByVal Database As
enmDatabaseFormat) As String
' Accepts a date input and outputs a database (SQL) specific
' string

If ActualDate = 0 Then
SQLFormatDate = "Null"
Else
Select Case Database
Case dbtMicrosoftAccess:
SQLFormatDate = "#" & Format$(ActualDate, "d-mmm-yyyy") & " " &
Format$(ActualDate, "Long Time") & "#"
Case dbtMicrosoftSQLServer, dbtSybase:
SQLFormatDate = "'" & Format$(ActualDate, "yyyy-mm-dd") & " " &
Format$(ActualDate, "hh:mm:ss.000") & "'"
Case dbtOracle:
SQLFormatDate = "TO_DATE('" & Format$(ActualDate, "mm-dd-yyyy") &
"', 'mm-dd-yyyy')"
Case Else
Err.Raise errdbcUnknownDatabaseFormat, "dbConnection", "The database
format is unknown"
End Select
End If

End Function
 >> Stay informed about: SQL Date Between Problem 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> Visual Basic -> DAO All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]