how to convert time field into string using linq sql? - linq

i am using linq to fetch the data and converting time field into string.
At that time if i have a value 11:00:00 in time field of sql server.
But i am getting "Jan 1 1900 11:00AM" at the time of converting to string.
Please provide me help to fetch only time part.
Thanks in advance..

Try this:
yourDateTimeObject.ToString("HH:mm:ss")
Or as Mark Seemann suggested:
yourDateTimeObject.TimeOfDay.ToString()

It sounds like the field is of type DateTime. You can use the TimeOfDay property to get only the time part.
timeField.TimeOfDay

Related

Spring Boot Query on Date field without time

I have an entity with a Date field with type of java.util.Date, and this field in oracle db has the timestamp type.
the problem is that when i use the repository to find by given specs, it returns nothing for the given date.
It only happens when i want the exact equal date. it works fine with greaterThen and lessThen and that's because the time of the saved records are different.
how could I ignore the time of records and fetch them only for the given date?
Thanks a million
I think you need to look at #Temporal #JsonFormat annotations. Link
Sample usage;
#Temporal(TemporalType.TIMESTAMP)
#JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MMdd'T'HH:mm:ss")
protected Date lastUpdate;
because the data was saved with the time best way was to do it with between condition from 00:00 to 23:59 in that day. special thanks to this link :
Spring Data Querying DateTime with only Date
but i solved the problem by creating a view from that table and removing the time from the date in oracle.

not giving perfect result

Time and date both are different fields but when I use this coding result is not perfect.
This is my code:
$challenges = Challenge::whereDate('c_date','>',Carbon::now())->get();
Challenge::whereTime('c_time','>',Carbon::now())->get();
Are there any problems in this code?
Firstly check the formate of date in c_date.Format should be ('Y-m-d').If your formate is okay then check your logic that what you really want?
I think your fault is your logic .You want to get those date where c_date is grater then now date.
$challenges = Challenge::whereDate('c_date','<',Carbon::now())->get();

how to convert this string '2014-12-31T05:00:00.000+00:00' into date in informatica

i have my date coming in string form :'2014-12-31T05:00:00.000+00:00'
how can TO convert this into date format in informaticA
Take a sub string of the time string '2014-12-31T05:00:00.000+00:00' to '2014-12-31' after all you need date part only.
Then parse the date using to_date method.
to_date('substring date','yyyy-dd-mm')
You can use this:
to_date('2014-12-31T05:00:00.000+00:00', 'YYYY-MM-DD.HH:MI:SS.MS......')
Keep in mind that it ignores the time zone information.

How can I format a date in the Select property of an EntityDataSource

Fairly straight forward... I have an EntityDataSource where, in the Select property I'm pulling a variety of fields. One of which is a Date that I would like to have returned in the "MM/dd/yyyy" format. How can I accomplish this?
You could use the .ToString(Format Here)
DateTime time = EDS.Field;
Console.WriteLine(time.ToString(MM/dd/yyyy));
This solution works fine with me:
cast(it.[interview_start_date] as System.String)

Activerecord removes all zeros from the timestamp field

I am using Ruby on rails. I am trying to retrieve timestamp column from particular table.
Activerecord returns me the date, if timestamp contains all zeros.
e.g: If timestamp stored is 2010-09-06 00:00:00:000, it returns me 2010-09-06.
But if I have 2010-09-06 00:00:20:000, it returns me in the expected format(i.e: 2010-09-06 00:00:20:000).
This leads to inconsistency. Please help me improve on this.
All suggestions are welcome.
Thanks in Advance.
Sachin
What is the type of the returned object? If that's String, you may manually add missing parts, but if that is a Time object, then you may use a .strftime() method:
t + " 00:00:00.0000" if t =~ /^[-0-9]{10}$/
t.strftime("%Y-%m-%d %H:%M:%S.") + t.usec.to_s

Resources