Date modification

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gerles
    New Member
    • Nov 2007
    • 1

    Date modification

    I need to get the current date and put it into the following format:
    yyymmdd tttttt

    I then need to subtract 24 hours from it and so that I can use that time for an SQL query.

    Any help would be greatly appreciated!
    Thanks,
    Gabe
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by gerles
    I need to get the current date and put it into the following format:
    yyymmdd tttttt

    I then need to subtract 24 hours from it and so that I can use that time for an SQL query.

    Any help would be greatly appreciated!
    Thanks,
    Gabe
    Hi there, this might be of help:

    Format(Date + Time, "yyyymmdd ttttt")
    Format(Date + Time - 1, "yyyymmdd ttttt")

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      What version of VB? In VB6, you can use Now to return the current date and time in one go.

      Comment

      • Mohan Krishna
        New Member
        • Oct 2007
        • 115

        #4
        Hi GERLES

        This might help you...

        Text1.Text = Format(Date + Time, "YYYYMMDD HHMMSS")
        or
        Text1.Text = Format(Now, "YYYYMMDD HHMMSS")

        ALL THE BEST!
        Last edited by Mohan Krishna; Nov 21 '07, 05:09 AM. Reason: Forgot other code

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by Mohan Krishna
          Text1.Text = Format(Now, "YYYYMMDD HHMMSS")
          Actually, minutes are "N" not "M". Gotta watch that...

          Comment

          • Mohan Krishna
            New Member
            • Oct 2007
            • 115

            #6
            Originally posted by Killer42
            Actually, minutes are "N" not "M". Gotta watch that...
            Hi KILLER42!

            It is working in both ways! Why?

            Comment

            • lotus18
              Contributor
              • Nov 2007
              • 865

              #7
              Originally posted by Mohan Krishna
              Hi KILLER42!

              It is working in both ways! Why?
              Yes. Killer is right. MM for month and NN for minutes.

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                Originally posted by lotus18
                Yes. Killer is right. MM for month and NN for minutes.
                Yes, you have to be careful or you'll find that the minutes are always 11 (or whatever), because it's actually showing the month.

                Comment

                Working...