Jump to content
Server Maintenance This Week. ×

Differing Date formats


This topic is 6991 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

Hi,

This is probably a simple one!

I have 2 databases each with a field 'dateastext'. One is a global, and one isn't, but they are both Text format fields.

In my script, I:

Set Field[file1::dateastext;GetAsText ( Get ( CurrentDate ))]

which in one file returns:

3/3/04

and in the other returns:

3/03/04

and as a result I cannot link the two files on the date field for a portal lookup!

Do you clever chaps (and chappesses) know and way to standardise the return...

TIA,

Bob

Link to comment
Share on other sites

I'm not certain what would cause this, but you could always use

Right( "0" & Month(Get(CurrentDate)); 2 ) & Right( "0" & Day(Get(CurrentDate)); 2 ) & Year(Get(CurrentDate))

as your calculation.

Link to comment
Share on other sites

You could also try cloning the files, to make sure they inherit the system's format. And/or in File Options.. Text, check Always use current system's settings.

But truth to be said, relying on a date to text conversion is always iffy. Why not simply use the date as date, or as a number?

Link to comment
Share on other sites

Building on what Queue said, generally speaking you should make your relationships dependent on a calculation which formats consistently no matter what the system date or other input format is, such as by means of the calculation he includes.

You can still use the text date field for other things, but by picking apart and reassembling via calculation the date, you can guarantee the required consistency.

Link to comment
Share on other sites

  • Newbies

Thank you all - the

Right( "0" & Month(Get(CurrentDate)); 2 ) & Right( "0" & Day(Get(CurrentDate)); 2 ) & Year(Get(CurrentDate))

Code sorted it beautifully. I agree about the comments in using a unique number (but in my case there was a skills shortage in effecting this!)

Much happier now....

Thanks again,

Bob

Link to comment
Share on other sites

This topic is 6991 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.