Results 1 to 9 of 9

Thread: Date unpossibility?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455
    Hello VB programmers,

    In my program I do have to find out or a field (format Date) is greater then a string date:

    Field Paid is format Date

    source:

    Private Sub Form_Load()
    Dim DB As Database
    Dim RS As Recordset
    Dim DT As String

    DT = "3/1/00"

    Set DB = OpenDatabase("c:\q.mdb")
    Set RS = DB.OpenRecordset("select * from SubScribers")

    If RS!PaidThrough > DT Then
    q = q
    Else
    q = q
    End If
    End Sub

    When the value of PaidThrough = 1/3/99 the field is allway greater then DT.

    Is there any possibility to convert a string to a date to get a correct answer.

    Nice regards,

    Michelle.



  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Declare DT as a date, not a string

    when you set it set it with

    DT=#3/1/99#

    Hope this helps

  3. #3
    Guest
    You can convert a string to a date with the CDate function

    Code:
    Dim sDate as String
    
    sDate = "02-01-2000"
    
    If CDate(sdate) > "01-01-2000" Then
     Debug.Print "Yes, the date is higher"
    Else
     Debug.Print "No, the date is not higher"
    End if
    -Kayoca Mortation

  4. #4
    Guest
    You can convert a string to a date with the CDate function

    Code:
    Dim sDate as String
    
    sDate = "02-01-2000"
    
    If CDate(sdate) > "01-01-2000" Then
     Debug.Print "Yes, the date is higher"
    Else
     Debug.Print "No, the date is not higher"
    End if
    -Kayoca Mortation

  5. #5
    Guest
    You can convert a string to a date with the CDate function

    Code:
    Dim sDate as String
    
    sDate = "02-01-2000"
    
    If CDate(sdate) > "01-01-2000" Then
     Debug.Print "Yes, the date is higher"
    Else
     Debug.Print "No, the date is not higher"
    End if
    -Kayoca Mortation

  6. #6
    Guest
    You can convert a string to a date with the CDate function

    Code:
    Dim sDate as String
    
    sDate = "02-01-2000"
    
    If CDate(sdate) > "01-01-2000" Then
     Debug.Print "Yes, the date is higher"
    Else
     Debug.Print "No, the date is not higher"
    End if
    -Kayoca Mortation

  7. #7
    Guest
    You can convert a string to a date with the CDate function

    Code:
    Dim sDate as String
    
    sDate = "02-01-2000"
    
    If CDate(sdate) > "01-01-2000" Then
     Debug.Print "Yes, the date is higher"
    Else
     Debug.Print "No, the date is not higher"
    End if
    -Kayoca Mortation

  8. #8
    Guest
    Sorry, I hat a system hangup. i have pressed to much the buttons....

    -Kayoca Mortation

  9. #9
    Hyperactive Member Juan Carlos Rey's Avatar
    Join Date
    Aug 1999
    Location
    Mendoza, Argentina
    Posts
    301
    Hi, kayoca.

    You (and only you) can delete your duplicates clicking on "edit/delete".




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width