ALFANI Posted February 28, 2013 Report Posted February 28, 2013 I’m using below query… Getting month and date but not hour while extracting from table …throwing error Hour line add cheyaganey An unexpected token "EXTRACT(month FROM DT_SVC_STARTD) "month", EXTRACT(day" was found following "SELECT ". Expected tokens may include: "<space>". SQLSTATE=42601 select extract(month from DT_SVC_STARTD) as mon, extract(day from DT_SVC_STARTD) as dy, --extract(Hour from DT_SVC_STARTD) as hh count(DT_SVC_STARTD) as Trans FROM UDBADM.RDSTMP where extract(year from DT_SVC_STARTD) > 2011 group by extract(month from DT_SVC_STARTD),extract(day from DT_SVC_STARTD) --extract(Hour from DT_SVC_STARTD) order by mon,dy; using rapidsql tool over sybase..datetime format "2011-12-11-07.56.07.651000" need to figure out peak hour transaction from a year...year lo e month lo e date e hour lo inni trasactions jariginooo kavali
loveindia Posted February 28, 2013 Report Posted February 28, 2013 ee extract endi??? SQL lo ee function kosam DATEPART anedi undi kada... use that.. google chey DATEPART ani... DAY MONTH YEAR HOUR MINUTES SECONDS anni vastai... use that.. Thanks
dravia Posted February 28, 2013 Report Posted February 28, 2013 You can also use substring function in sql to extract a part of any string. substring([i]expression[/i], [i]start, length[/i] )
loveindia Posted February 28, 2013 Report Posted February 28, 2013 [quote name='dravia' timestamp='1362075661' post='1303345233'] You can also use substring function in sql to extract a part of any string. substring([i]expression[/i], [i]start, length[/i] ) [/quote] substring aaa... DATEPART ani built in function untey malli calculated field enduku... Anavasaram aina overload tappa query meeda... Use like this... SELECT GETDATE() AS 'TimeStamp' , DATEPART(D,getdate()) AS 'Day' , DATEPART(M,getdate()) AS 'Month' , DATEPART(YYYY,getdate()) AS 'Year' , DATEPART(HH,getdate()) AS 'Hour' , DATEPART(MINUTE,getdate()) AS 'Minute' , DATEPART(SECOND,getdate()) AS 'Second'
dravia Posted February 28, 2013 Report Posted February 28, 2013 [quote name='loveindia' timestamp='1362076036' post='1303345252'] substring aaa... DATEPART ani built in function untey malli calculated field enduku... Anavasaram aina overload tappa query meeda... Use like this... SELECT GETDATE() AS 'TimeStamp' , DATEPART(D,getdate()) AS 'Day' , DATEPART(M,getdate()) AS 'Month' , DATEPART(YYYY,getdate()) AS 'Year' , DATEPART(HH,getdate()) AS 'Hour' , DATEPART(MINUTE,getdate()) AS 'Minute' , DATEPART(SECOND,getdate()) AS 'Second' [/quote] adi just an alternative ki cheppa [size=4] ..[/size][size=4] [/size]
loveindia Posted February 28, 2013 Report Posted February 28, 2013 ela cheptaavu vayya alternative ani... takita takita takita 2 4.. takadimi takadimi 2 6.. aa tempo enti ee tempo enti.. aa query enti ee query enti.. (Just for fun)
dravia Posted February 28, 2013 Report Posted February 28, 2013 Nadi ETL bro work,so koddiga week anmata SQL lo [size=4] ..[/size]
chicago Posted February 28, 2013 Report Posted February 28, 2013 EXTRACT(HOUR FROM timestamp) ...i guess your question is resolved...
chicago Posted February 28, 2013 Report Posted February 28, 2013 [quote name='dravia' timestamp='1362075661' post='1303345233'] You can also use substring function in sql to extract a part of any string. substring([i]expression[/i], [i]start, length[/i] ) [/quote] please bhaiyya thana question enti meeru emi answer esthunaru ...i didnt get you
calmandquiet Posted February 28, 2013 Report Posted February 28, 2013 [size=4] [/size][size=4] [/size]
dravia Posted February 28, 2013 Report Posted February 28, 2013 [quote name='m8espartan' timestamp='1362077261' post='1303345333'] please bhaiyya thana question enti meeru emi answer esthunaru ...i didnt get you [/quote] [size=4][font=arial, sans-serif]substring("YYYY-MM-DD HH:MM:SS",12,13) returns HH,anything wrong?[/font][/size]
goli soda Posted February 28, 2013 Report Posted February 28, 2013 [quote name='dravia' timestamp='1362077640' post='1303345358'] [size=4][font=arial, sans-serif]substring("YYYY-MM-DD HH:MM:SS",12,13) returns HH,anything wrong?[/font][/size] [/quote] this will not work..... substring is just used to give part of that string.... ikkada date part function vadali.....
dravia Posted February 28, 2013 Report Posted February 28, 2013 [quote name='goli soda' timestamp='1362077879' post='1303345394'] this will not work..... substring is just used to give part of that string.... ikkada date part function vadali..... [/quote] k Thanks..
goli soda Posted March 1, 2013 Report Posted March 1, 2013 dude yee problem solve ayinda? nuvvu sybase annavu... but extract command sybase lo ledu kada......
Darling999 Posted March 1, 2013 Report Posted March 1, 2013 [quote name='goli soda' timestamp='1362155958' post='1303349856'] dude yee problem solve ayinda? nuvvu sybase annavu... but extract command sybase lo ledu kada...... [/quote] Alelooya, same qochen goli
Recommended Posts