date issue

Results 1 to 3 of 3

Thread: date issue

  1. #1
    ed Guest

    Default date issue

    I have 2 fields(StartTime and EndTime) in Access database with date/time format.The StartTime and EndTime may store date only<BR>or date with time.<BR><BR>I have problem to retrieve those record that match today date, meaning if the record has starttime or endtime equal to today or<BR>if today fall between StartTime and EndTime.<BR><BR>My sql statement is as below.<BR>Select * from Schedule Where <BR>(CDATE(StartTime) = &#039;"& DateAdd("d", dt, Date()) &"&#039; or <BR>CDATE(EndTime) = &#039;"& DateAdd("d", dt, Date()) &"&#039;) and <BR>(CDATE(StartTime) &#060;= &#039;"& DateAdd("d", dt, Date()) &"&#039; and <BR>CDATE(EndTime) &#062;= &#039;"& DateAdd("d", dt, Date()) &"&#039;))<BR><BR>Can somebody help me.Thanks.<BR>p/s how to extract only date in a date/time format in access database.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: date issue

    Why are you using DateAdd??? Your question asks about records matching "today[&#039;s] date", but DateAdd is going to give you a *different* date! Why in the world are you calling it???<BR><BR>And in Access, you use the "DateValue" function to get just the date from a date/time field, same way you do in ASP and VBScript.<BR><BR>So:<BR><BR>SELECT * FROM Schedule<BR>WHERE DateValue(StartTime) &#060;= Date()<BR>AND DateValue(EndTime) &#062;= Date()<BR><BR>and that *should* be all you need.<BR><BR>

  3. #3
    ed Guest

    Default RE: date issue

    thanks.I got it.<BR><BR>I used dateadd bec if user select today date, dt will be 0 and pass it as a parameter, if user select next day or previous day, then 1 and -1 will be pass in respectively.

Posting Permissions

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