Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

convert a General Date into an ID

Posted on 2004-03-26
9
Medium Priority
?
281 Views
Last Modified: 2008-03-06
I need to convert a General Date (3/25/2004 3:16:34 PM) into a string or Intiger to be used as
an ID ei: 325200431634

I have tried a couple different things but nothing works....any ideas?
the Date is stored in the field "Date_and_Time_Of_Occurance"
0
Comment
Question by:Sebastian_c
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 10687813
use the format command

sID = Format(myDate,"MMDDYYYYNNMMSS")
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10687822
sorry, that should be HHNNSS not NNMMSS

0
 
LVL 54

Expert Comment

by:nico5038
ID: 10687935
When just an ID is needed, simply change the date into a number field. :-)

It will have decimals for the hours/minutes/sec part, but an update query with * 100000 can "remove" that when needed.

Nic;o)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Expert Comment

by:goliak
ID: 10687964
You can simply manually change the data type of your field to double or single type. The result slightly reminds a date but you'll get an ID field. Also that field easely converts back to Full Date.
0
 

Author Comment

by:Sebastian_c
ID: 10687983
Thats works great! BUT when I use Date, it gives a number 03262004000000
What happened to the HHMMSS?
BTY You get the points rockiroads!
0
 

Author Comment

by:Sebastian_c
ID: 10688303
How do I declair General Date in the eqation:

sID = Format(myDate,"MMDDYYYYNNMMSS")
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 120 total points
ID: 10688527
did your date have a time in it? dump your date you wish to convert

if you look in help on the Format command, there are plenty of types you can change it to

when you mean declare Generate Date in the equation, what do you mean? do you want to return a General Date?

you can use Format(myDate,"General Date")

but basically, format takes any date or date/time and formats it to any style you want (again, see help for otpions)


some examples
Dim MyTime, MyDate, MyStr
MyTime = #17:04:23#
MyDate = #January 27, 1993#

' Returns current system time in the system-defined long time format.
MyStr = Format(Time, "Long Time")

' Returns current system date in the system-defined long date format.
MyStr = Format(Date, "Long Date")

MyStr = Format(MyTime, "h:m:s")    ' Returns "17:4:23".
MyStr = Format(MyTime, "hh:mm:ss AMPM")    ' Returns "05:04:23 PM".
MyStr = Format(MyDate, "dddd, mmm d yyyy")    ' Returns "Wednesday,
    ' Jan 27 1993".
' If format is not supplied, a string is returned.
MyStr = Format(23)    ' Returns "23".

' User-defined formats.
MyStr = Format(5459.4, "##,##0.00")    ' Returns "5,459.40".
MyStr = Format(334.9, "###0.00")    ' Returns "334.90".
MyStr = Format(5, "0.00%")    ' Returns "500.00%".
MyStr = Format("HELLO", "<")    ' Returns "hello".
MyStr = Format("This is it", ">")    ' Returns "THIS IS IT".

0
 

Author Comment

by:Sebastian_c
ID: 10689066
Thank you rocki!
I ended up using: sID = Format(Time, "MMDDYYYYHHMMSS")
which gives me a unique number each time...

Sebastian
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10689149
ok, just to note, did you lose the leading zero?
if you did and you dont want to lose it, how about putting YYYY first, just a thought

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question