Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ASP - problem with DATE field
Message
From
12/12/2006 12:55:47
 
 
To
12/12/2006 12:51:03
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
01176801
Message ID:
01176922
Views:
12
>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
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform