Jump to content

SQL query in vb6 Help

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
avosoft

avosoft

    Learning Programmer

  • Members
  • PipPipPip
  • 47 posts
Hello guy!

AM doing a query against database, but its not working

sSQL = "SELECT * FROM tasks WHERE due_date = " & MakeUSDate(Now) & _

    " AND due_time < " & MakeUSTime(Time)


The date and time function


' Make US date and time


Function MakeUSDate(X As Variant) As String

    If Not IsDate(X) Then Exit Function

    MakeUSDate = "#" & Month(X) & "/" & Day(X) & "/" & Year(X) & "#"

End Function


Function MakeUSTime(X As Variant) As String

    If Not IsDate(X) Then Exit Function

    MakeUSTime = "#" & Hour(X) & ":" & Minute(X) & ":" & Second(X) & "#"

End Function

any help here!:)
Programming is all about good logic. Spend more time here

vHost for Apache:thumbup1:

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What type of database are you running this against? Depending on the type, you may need to delimit the date with single quotes, hash marks, or something else.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
avosoft

avosoft

    Learning Programmer

  • Members
  • PipPipPip
  • 47 posts
Hello,

Am ruining it against Ms Access
Programming is all about good logic. Spend more time here

vHost for Apache:thumbup1:

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
http://msdn.microsof...%28SQL.90).aspx
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
avosoft

avosoft

    Learning Programmer

  • Members
  • PipPipPip
  • 47 posts
Thanks for your response i found out that is was the way i saved my date and time in access database.
i changed the time to datatype mediumtime and date to short date i also used this to format time Format$(time,"h:nn AM/PM")
Programming is all about good logic. Spend more time here

vHost for Apache:thumbup1:

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I'm glad I could help :)
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog