on 03-21-2013 5:52 AM
Hi,
We have a Column called Event_Date in SQL server 2008. The data is recording in this format YYYY-MM-DD HH:MM:SS:MS. i want the data in such away that, the date should be in one column and the Time should be in another column. The Date should be saved in this format.
Date: DD-MM-YYYY
Time: HH:MM
Can someone guide me how to achieve this?
Hi, first separate YYYY-MM-DD from HH:MM:SS:MS by having substring (0,9) for YYYY-MM-DD & (10,14) for HH:MM:SS:MS since you only need HH:MM. Map the subtsing (10,14) directly to the field to store HH:MM & for the date field after substring(0,9) apply the date function to change the input date format of YYYY-MM-DD into DD-MM-YYYY
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Use the below udf.Pass input date ,Inputdate format and output date format as inputs.
String outputDate;
SimpleDateFormat SDFInput = new SimpleDateFormat(inputDateFormat[0]);
SimpleDateFormat SDFOutputDate = new SimpleDateFormat(outputDateFormat[0]);
if(inputDate[0]!="") {
if(inputDate[0].length()==inputDateFormat[0].length()){
try{
Date date = SDFInput.parse(inputDate[0]);
outputDate.addValue(SDFOutputDate.format(date));
//Split ur date and time and pass it to output
}catch(Exception e) //It is up to you
{}
Regards
Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.