How to extract date


#1

how to extract date (yyyy.mm.dd) from a date in mapd without timestamp
output should be 2018.12.23
but i am getting output as “03 Jan 2018 00:00:00 GMT”


#2

@nagulan can you please provide a sample of your data, as well as the query you are using?


#3

@easy
yes i am using pymapd in python
this is my code:

from sqlalchemy import select,literal_column,create_engine
from pymapd import connect

res = c.execute(“select ord_cre_dt AS date1 FROM snidata”)
print(res.fetchall())


#4

This should helps

e.g.
from sqlalchemy import select,literal_column,create_engine
from pymapd import connect
con = connect(‘mapd://mapd:HyperInteractive@deepbox.thickdata.io:9091/mapd?’‘protocol=binary’)
c = con.cursor()
res = c.execute(“select ord_cre_dt AS date1 FROM snidata”)

for row in res:
print row[0].strftime(’%Y.%m.%d’)

the date is returned as an object and you can format as you want

printing without formatting will get a default format