MapInfo - convert date when exporting as CSV

602 views
Skip to first unread message

Paul Barrington

unread,
Sep 2, 2013, 11:38:17 AM9/2/13
to mapi...@googlegroups.com
Hi,

I'm creating a workspace using MapBasic to try and automate some of the procedures we follow in the office. I'm stuck though...

I have written scripts to pull all of the data required into a single table. I am then currently using Export overlap_tab Into "data/tabular_data.csv" Type "CSV" Delimiter "," Titles to export the table as a csv.

This bit works fine. However the date is formatted as YYYYMMDD and we want it to display as dd/mm/yyyy when the csv is opened using Excel. At the moment we manually convert the yyyymmdd to dd/mm/yyyy using a macro in Excel. I would like to know if it is possible to change this in MapInfo as part of the export process, even if this means changing the SQL i.e. SELECT xxx, yyy, FormatDate(ddmmyyyy, date) AS date...

Thanks for reading

Paul

Greg

unread,
Sep 3, 2013, 5:38:06 AM9/3/13
to mapi...@googlegroups.com
Hi,
 
Have you had a look at FormatDate$() MapBasic function?  This will convert a date to the short date format specified in the Control Panel settings.  I think converting the date to a string will also keep the current format: slelect xxx, yyy str$(date_column) from......
 
 
HTH

Greg.

Thomas Bacon

unread,
Sep 3, 2013, 5:49:29 AM9/3/13
to mapi...@googlegroups.com

Paul,

 

You could also use the Day(), Month(), and Year() functions to guarantee the formatting you require.

 

e.g.

 

Dim date as String

date = Day(CurDate()) & "\" & Month(CurDate()) & "\" & Year(CurDate())

Print date

 

This prints the string “3\9\2013”. Saying that, your short date format will probably give you what you are after as Greg suggested. Just another option.

 

Regards,

 

Tom Bacon

GIS Engineer, Mouchel

T 01444 472380 │ E thomas...@mouchel.com W www.mouchel.com

Our values: innovation │ excellence │ integrity │ responsibility

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
 
---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Mouchel logo

Mouchel Limited (Mouchel) is registered in England and Wales with registered number 01686040 at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX.  The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. No contracts may be concluded on behalf of Mouchel by means of email communications. Mouchel reserves the right to monitor and intercept emails sent and received on our network. 

Reply all
Reply to author
Forward
0 new messages