Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ASP - problem with DATE field
Message
From
14/12/2006 08:13:28
 
 
To
12/12/2006 12:55:47
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
01176801
Message ID:
01177547
Views:
8
>>Thank a lot. This one is works as well as without '^'.
>
>This VB.NET function converts a date format for a SQL command into a format as per the backend. It might be useful to you. This can be easily adapted in the environment of your choice. The code is pretty straight forward. Usually, I will build my SQL like this:
>
>
>lcSQL="SELECT Member.FirstName FROM Member WHERE Member.AddDate>="+DateUniversal(Date.Now,1)
>
>
>
>        ' Return a date in a universal format
>        ' expD1 Date
>        ' expN1 Backend
>        Public Function DateUniversal(ByVal tdDate As Date, ByVal tnBackend As Integer) As String
>            Dim lcDate As String = ""
>            Dim lnDay As Integer = 0
>            Dim lnHour As Integer = 0
>            Dim lnMinute As Integer = 0
>            Dim lnMonth As Integer = 0
>            Dim lnSecond As Integer = 0
>            Dim lnYear As Integer = 0
>            lnDay = tdDate.Day
>            lnMonth = tdDate.Month
>            lnYear = tdDate.Year
>            lnHour = tdDate.Hour
>            lnMinute = tdDate.Minute
>            lnSecond = tdDate.Second
>
>            ' Different backends handle it differently
>            Select Case tnBackend
>
>                ' Visual FoxPro
>                Case 1
>                    lcDate = lcDate + "{^"
>                    lcDate = lcDate + Trim(lnYear.ToString) + "/" + lnMonth.ToString.PadLeft(2, "0") + "/" + _
>                     lnDay.ToString.PadLeft(2, "0") + " " + lnHour.ToString.PadLeft(2, "0") + ":" + _
>                     lnMinute.ToString.PadLeft(2, "0") + ":" + lnSecond.ToString.PadLeft(2, "0")
>                    lcDate = lcDate + "}"
>
>                    ' SQL Server
>                Case 2
>                    lcDate = lcDate + "'"
>                    lcDate = lcDate + lnMonth.ToString.PadLeft(2, "0") + "/" + lnDay.ToString.PadLeft(2, "0") + "/" + _
>                     Trim(lnYear.ToString) + " " + lnHour.ToString.PadLeft(2, "0") + ":" + _
>                     lnMinute.ToString.PadLeft(2, "0") + ":" + lnSecond.ToString.PadLeft(2, "0")
>                    lcDate = lcDate + "'"
>
>            End Select
>
>            Return lcDate
>        End Function
>
Unfortunately my software choice is limited to ASP(VBScript,JavaScript) only.
BTW, your version of sentence (with '^') doesn't caused an error but returning the wrong recordset while sentence without '^' works fine.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform