datetime-format

DateTime is specially formatted unexpected in web service call

Environment: IIS 6.0 In my web service there is only a simple web method that return the current cultrue and DateTime format: [WebMethod] public string GetDateTimeInfo() { string culture = Thread.CurrentThread.CurrentCulture.Name; string dt = DateTime.Now.ToString(); string ...

Filtering in Python/Django based on date, ignoring time

I'd like to filter objects to the day with datetime, but can't find examples on how to do this anywhere. This, for example, works perfectly in pulling together all following events: @login_required def invoice_picker(request): """Grab a date from the URL and show all the invoicable deliveries for that day.""" query = request.GE...

Datetime format help

Hi all... I want only Hr and Min in time format so i did select convert(varchar(20),GETDATE(),108) ===>> output is "12:57:54" but i want only "12:57" this much so how i will do that in sql server ...

date from string help. I can convert to the string I want, but I can't convert back.

I have a string I need to convert back to a date. I can call .ToString("yyyyMMdd") and get the string i want. My question is how can I convert that back into a date? I'm trying something like the following with no luck. DateTime d; var formatInfo = new DateTimeFormatInfo {ShortDatePattern = "yyyyMMdd"}; if (DateTime.TryParse(details.Det...

How to get an isoformat datetime string including the default timezone?

I need to produce a time string that matches the iso format yyyy-mm-ddThh:mm:ss.ssssss-ZO:NE. The now() and utcnow() class methods almost do what I want. >>> import datetime >>> #time adjusted for current timezone >>> datetime.datetime.now().isoformat() '2010-08-03T03:00:00.000000' >>> #unadjusted UTC time >>> datetime.datetime.utcnow(...

How to format a datetime with minimal separators and timezone in VBScript?

I have the following code in C#: DateTime dt = GetDateTime(); string formatted = dt.ToString("yyyyMMddTHHmmsszz"); which returns a date in the following format: 20100806T112917+01 I would like to be able to get the same results in VBScript (for a legacy ASP application). It is especially important that I get the UTC offset informat...

set date variable to 8pm last night

Hi I'm wanting to set a variable date in the format Y-m-d 20:00:00 of the previous day. can someone help? ...

Date Time create from format

Hi, I want to create date with specific format for e.g 03-20-2010 have a format of m-d-Y but date function do not understand this date and returns wrong date $date = date("Y-m-d", strtotime("03-20-2010")); Above code is returning wrong date, what is the reason behind it and how to avoid wrong result? Few formats that I want date funct...

Strange DateTime.ToString behavior

I have the following line of code inside of a function: String value = endDate.Value.ToString(dateFormatStr); //endDate is a DateTime? object (returned from a LINQ to SQL query). In the particular instance I am experiencing odd behavior, the value of endDate is {10/2/2010 12:00:00 AM}. Here's my results: dateFormatStr="d" => value="1...

Add the current time to a DateTime?

Hello, I have a string which represents a date, its given back from a DropDownList. The string is "27.08.2010" for example. Now I want to add the current time to this and parse it to Datetime ... so in the end it should be a DateTime like 27.08.2010 15:12:45 for example. How could I do this? Right now, I am putting together a string usi...

Ruby DateTime format: How can I get 1st, 2nd, 3rd, 4th?

First of all, it doesn't seem that the DateTime format variables are documented anywhere so a +1 to anyone who can show this to me in rubydocs. Second of all, when looking at the Date.strftime function code, I don't see anything that can let me do something like: Thursday, September 9th 2010 Does anyone know if this is possible? ...

Converting to and from datetime adds an hour?

Hi, I am writing a fairly large webapp in asp.net / c# with mssql 2008 r2 serving the database. The program needs to convert date/time strings (in ISO date format) to DateTime where they are used and later stored as smalldatetime in sql. When the strings are converted to datetimes, an hour is mysteriously added to the result. I underst...

Using a datetime as filename and parse the filename afterwards?

Hello, I am writing files to my harddrive,The filename is build like this: String.Format("{0:yyyy-MM-dd_hh-mm-ss}.txt", DateTime.Now) So the filename is "2010-09-20_09-47-04.txt" for example. Now I want to show those filenames in a dropdown, but with another format. The format should be dd.MM.yyyy HH:mm:ss. How can I do that, or is th...

How to force 24 hour time in Telerik's RadDateTimePicker and keep the date formatting as "d"?

I'm using Telerik's RadDateTimePicker to select the time of the event in my web-app (ASP.NET, .NET 3.5). The application is targeting multiple countries, my date formatting is taken care of based on users' CultureInfo. There's one problem, I need the time part of the date/time to ALWAYS show in 24 hour format, no matter what Culture...

C# Time Formatting. Localization to French how do I get the output "5h 45" for 5:45?

I'm attempting to format dates for a French customer. I need to format Times as shown in the following examples... 06:00 -> 6 h 08:45 -> 8 h 45 10:30 -> 10 h 30 15:00 -> 15 h 17:22 -> 17 h 22 18:00 -> 18 h I've been able to use Custom Date and Time Formatting. But I seem to be stuck on this notation that the French (Canad...

datetime not accepting by asp.net mvc 2

Hi, I have application in asp.net mvc 2. one of form in create user. but this form is not accepting date format of dd/MM/yyyy and MM/dd/yyyy i want to allow MM/dd/yyyy for save in db what have to do. i am am using c# language . ...

Activerecord removes all zeros from the timestamp field.

Hi, 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:...