Convert Date Format

Hello All,

I am now learning Data services and I have a basic question in converting Date format.
I have “Order Date” column in Order table with Data type DateTime and the format is ‘yyyy.mm.dd 00:00:00’.
Now I want to convert this dateTime into Data field of format “mm-dd-yyyy”. Please let me know how to convert this. I used a query transform to make this Datetime into Date column and it gave the output as “yyyy.mm.dd” from Date time. Please let me know how to convert this Date format. I am using SQL server 2008 as backend.

Louis


louisbo (BOB member since 2012-09-11)

Check the to_date() in the documentation :wink:


Johannes Vink :netherlands: (BOB member since 2012-03-20)

I have seen the to_date description as “Converts a string to a date under control of format string”. Please let me know if this works here. One more basic question… Should I go for BODS functions or SQL server functions as I am using BODS on SQL server?


louisbo (BOB member since 2012-09-11)

The documentation, as in the pdf files. Not the documentation in the Designer it self. In the installation path is: \Doc\Books\en, there is a set of pdf files.

You are working on BODS, thus implement the BODS logic to_date. BODS translates it to the local database language. BODS is very Oracle minded in its functions, but will translate it correctly.


Johannes Vink :netherlands: (BOB member since 2012-03-20)

There is sbo401_ds_designer_en.pdf in the forlder you mentioned. As per the pdf, I have used the workdate definition as
to_date(EMPHRS1.WORKDATE,‘mm.yyyy.dd’) but I get the output as Null in WorkDate column. Please help. Can you please give me the syntax if possible.


louisbo (BOB member since 2012-09-11)

You may have to use to_char and to_date functions simultaneously.

try this.

to_char(to_date(table1.col1,‘mm.yyyy.dd’),‘mm-dd-yyyy’)

Arun


Arun.K :us: (BOB member since 2011-10-18)

Hi Arun,

I tried this approach… I made the datetime to Date using one query transform and now it Workdate in the format of ‘yyyy.mm.dd’.
Now I used another query transform and used to_char(to_date(Query_Joining_EmphrsBasic.WORKDATE,‘yyyy.mm.dd’),‘mm-dd-yyyy’). But I get null values for the Workdate in Template table


louisbo (BOB member since 2012-09-11)

Whats your datatype in the template table? It should be varchar.

Arun


Arun.K :us: (BOB member since 2011-10-18)

Mine was date! Sorry!
Thans arun… Varchar worked :slight_smile:


louisbo (BOB member since 2012-09-11)

Nice! And now use the manuals as a good reference for the available functions and the syntax :wink:


Johannes Vink :netherlands: (BOB member since 2012-03-20)