how to convert the string of format(2019-09-01T02:55:10.000Z) to date in plsql - plsqldeveloper

how to convert a string of format'2019-09-01T02:55:10.000Z' to date in plsql?
I tried converting using to date function but it doesn't work

Try:
TO_DATE('2019-09-01T02:55:10.000Z', 'YYYY-MM-DDThh:mm:ss.fffTZD')

Related

Convert TZ datetime to summer/wintertime

I need to convert a TZ datetime like this:
2022-07-29T08:30:00Z
to fit the german time.
Unfortunately, Germany changes between summer and wintertime.
You can do a double Parse on the date if the date is in a string format.
Parse the date without the locale to convert it from a string and parse again with the locale.
Note that if your page locale is already set to DE, there is no need to double parse.
<cfscript>
newDate = lsParseDateTime("2022-07-29T08:30:00Z");
deDate = lsParseDateTime(newDate, "DE");
writeOutput(deDate);
</cfscript>
You can pass the third parameter to the function to format it.
https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-l/lsparsedatetime.html

Postgres conver json string to date format

I am pulling the close date from a json field using:
data->>'closeDate' as PortalCloseDate however this returns a string and I am trying to convert it to a date format. The date format in the string is YYYY-MM-DD so I tried (data->>'closeDate')::date but am getting the error: "ERROR: invalid input syntax for type date: "‎2020-‎12-‎09"" Any help is appreciated, thanks!
Try bruteforcing on cleaning and casting the string to date:
select
cast(replace(cast(data->>'closeDate' as varchar), '"','') as date) as "closeDate"
from table

How to deserialize date format in JSON date string?

This question someone is already asking and solution is with JavaScriptConverter (.NET) but how can I convert normal date into JSON date string with java script.
For example I have a formated date "12-12-2012" and I want to get string something like this example:
/Date(1354316400000+0100)/
Icky, awful format, and clumsy slow serializer. (IMHO)
On the server, use Json.Net and its default ISO8601 formatted dates instead.
On the client, use moment.js. It will handle all of the parsing and formatting you could want.
For posterity, if you want to output this format using moment.js, you can do one of these:
moment().format("[/Date](XSSS)/"); // /Date(1198908717056)/
moment().format("[/Date](XSSSZZ)/"); // /Date(1198908717056-0700)/
s = "12-12-2012".split("-");
epoch = Date.parse(s[2] + "-" + s[0] + "-" + s[1]);
output = "/Date(" + epoch + ")/";
if you need the timezone offset, you can use .getTimezoneOffset() on the Date Object and add that to your output string.

How do you compare dates in a LINQ query?

I am tring to compare a date from a asp calendar control to a date in the table.... here's what i have... it doesn't like the == ?
var query = from details in db.TD_TravelCalendar_Details
where details.StartDate == calStartDate.SelectedDate
&& details.EndDate == calEndDate.SelectedDate
select details;
In order for your query to work both details.StartDate and calStartDate.SelectedDate must be typed as System.DateTime.
What error are you receiving? Most likely one of these properties is a string and will need to be parsed into a DateTime instance for comparison.
What is the Type of details.StartDate and details.EndDate? Is it String? Maybe that's the problem. If the database type is String you should Parse the Date String into a DateTime and compare it with the calendar's selected date then.

How do I convert SQL's convert(varchar,datefield,106) to LINQ?

How do I convert SQL's convert(varchar,datefield,106) to LINQ?
You can get a string representation of a date by using ToString()
myDate.ToString()
and a date representation of a string by parsing it.
DateTime.Parse(myDateString)
You just need to include your conversion in your select clause.
from myRecord in myDataContext.MyTable
select new {myStringDate = myRecord.myDate.ToString()};