Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date format - is this possible? 2

Status
Not open for further replies.

coldan

Programmer
Oct 19, 2008
98
AU
I am decoding an Exif tag DateTime.

The value collected is in the form 2009:12:19 14:07:30 in my example

my code is

<code>

myvalue = ALLTRIM(Value)
mypos = AT(' ',myvalue)
mydate = SUBSTR(myvalue,1,mypos)
mytime = SUBSTR(myvalue,mypos,LEN(myvalue))
thisform.txtdatetime1.value = mydate
thisform.txtdatetime2.value = mytime

</code>

I would like to look at the 'International Settings/Region' of a particular PC and present the date correctly.

Is there a code snippet to show me how to easily
check the 'format' of the Exif DataTime tag based on the

2009:12:19 YYMMDD ?

Can I use VFP functions to get a 'converted' date string as required by the Region setting?

Thanks for any help

Coldan
 
I haven't used it but I think there are several. TTOD which I use all the time will pull out the date for instance. I think there is another tt funtion that will help you with the time.
 
Coldan,

Let me make sure I've understood this right.

You have a character string containing a date in YYYY:MM:DD format. You want to convert it a string that's in the user's date format, such as DD/MM/YYYY for British. Is that right?

If so, you can do something like this:

Code:
SET CENTURY ON
SET DATE TO ymd
SET MARK TO ":"
lcYMD = 2009:12:19"
ldDate = CTOD(lcYMD)

SET DATE SHORT
lcUserDate = DTOC(ldDate)
* lcUserDate will now contain 19/12/2009

The end-product of the above is a character string, lcUserDate, which contains the date formatted as per the "short date format" in the user's regional settings. You can also do SET DATE LONG if you want it to be in the long date format.

You can take a similar approach with the time element.

Does that answer your question? If not, perhaps you could clarify what you want to achieve.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Code:
lcValue = '2009:12:19 14:07:30'

? CTOT( '^'+Strtran(Alltrim(m.lcValue),':','/',1,2) )

would get you to what you need regardless of date settings.

Cetin Basoz
MS Foxpro MVP, MCP
 
Thanks Mike for the explanation and Cetin for a very neat solution.

Coldan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top