Time and date Fixing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aditya jha
    New Member
    • Nov 2010
    • 14

    Time and date Fixing

    I have two field in database one for date and other for Time.I want to save data in 3rd field. My office timing is 04:00 PM to 03:00 AM. Suppose that today is 30th Nov, when i save data between 04:00 PM to 11:59 PM it will save in 30th nov but if i save after 12:00 am then it takes next date. My question is how can i save that data in same day i.e. 30 Nov.
  • colintis
    Contributor
    • Mar 2010
    • 255

    #2
    If you are storing the date/time through VBA, you can use condition check and see if the time is between 12AM to 3AM
    Code:
    If Hour(<date>) >= 0 AND Hour(<date>) <=3 Then
        DateAdd("d",-1,<date>)
    End If

    Comment

    • Aditya jha
      New Member
      • Nov 2010
      • 14

      #3
      My query is: suppose today is 30 nov, if I save date in database before 11:59 PM it will save as 30th Nov but after 11:59 it save as next date. My office timing is 04:00 PM to 04:00 AM. So tell me how can i save date in between these timing.

      Comment

      • colintis
        Contributor
        • Mar 2010
        • 255

        #4
        Its something similar too, but in queries we use IIF function
        Code:
        IIF(Hour(<date>)MOD 24 >= 3, DateAdd("d",-1,<date>),<date>)
        This bit of function first check the if the hour contained in <date> is over 3 or not, which means the time between 12AM to 3AM. If it is true, then use DateAdd to take one day back (taking Dec 01 back to Nov 30). Otherwise it remains as what it is.

        Also, can you post your query of what you've done so far?

        Comment

        • Aditya jha
          New Member
          • Nov 2010
          • 14

          #5
          I have textbox on form. I want to input only numbers(0-9) and (.) from user. and if user input except these then cursor can't go to next object. if Textbox is blank then Tab works to goto next object. So please help me

          Comment

          Working...