Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Create date In Database from components

ParvathyK
5 - Atom

How can one create a date field in database from individual day, month and year fields?

4 REPLIES 4
jdunkerley79
ACE Emeritus
ACE Emeritus

If using the InDB tools the syntax will depend on the database connected to.

 

For SQL Server:

CONVERT(date,CONVERT(varchar(50),(Year*10000 + Month*100 + Day)), 112)

should work. Lots of details on https://stackoverflow.com/questions/35576983/how-to-create-a-date-in-sql-server-given-the-day-month-...

 

Oracle has a MakeDate function: https://docs.oracle.com/cd/B28359_01/olap.111/b28126/dml_functions_2019.htm#OLADM595

ParvathyK
5 - Atom

Thanks. I could make progress but I've still not got to the date format. 

 

I am using an Oracle server. However, the MakeDate function doesn't seem to work for me. The first link had used cast and I was able to get the date to a string like '20170918'. Any cues on how to convert string to Date format InDB?

jdunkerley79
ACE Emeritus
ACE Emeritus

You can convert with TO_DATE e.g.:

TO_DATE('19000101', 'yyyyMMdd')
ParvathyK
5 - Atom

It worked! Thank you very much!!

Labels
Top Solution Authors