datetime

Database-safe Date/Time String?

Which format of a date/time string would be considered cross-platform, cross-database, universal safe? Would this YYYY-MMM-DD HH:MM:SS be considered safe to use in MySQL, SQLite 2 & 3, MsSQL and other common databases? How about something like 2010-Jul-12 12:00:00pm? ...

Dynamically check timetable for clashes - jquery/php

Hi I'm making a timetable site for a music festival. The purpose of this site is for people to choose acts they want to see and compile their own personal timetable for the event. At the moment the site has 2 tables: The full list of acts on at the festival The user's personal timetable Here is my problem. Everytime an act is added...

SQL Datetime difference in days

I am trying to find how many days are between two dates. I have been attempting to use this: SET Days_Outstanding = DATEDIFF(day, CONVERT(datetime, LS_CHG_DTE_EQP, 1), CONVERT(datetime, Report_Date, 1)) However, this is not returning the number in days. It's returning a datetime in years that have nothing to do with my data set. ...

How do I perform a function using DateTime objects?

I want my .pl to execute a function at the end of every day, week and month. What the function will do is grab an integer from an html at the end of the day and store it in a .txt to be used to create a graph. I already know how to implement CGI and JS with a perl script, so that is no issue. I'm just not clear on whether or not DateTi...

Help me understand timezones (for shipping purposes)

I'm using a shipping api (with fedex), and some of the fields I need to fill out ask for the datetime in a certain format (I've heard some people call it "zulu", it looks like this: 2006-06-26T17:00:00-0400) (by the way, what's a good way to format this in php) I'm hoping to be able to do this by using zip codes. So if I know a user's z...

[VB.Net] Display `00` instead of `0` in a NumericUpDown control

Hello everyone! I'm letting users select a date/time for a scheduled task to run, using two NumericUpDowncontrols. I'd like one-digit values to be padded with a leading 0, so as to display 09:00 instead of 9:0. Any ideas? Thanks, CFP. ...

python datetime help

Hi, I have a big search field, where users could type in any peice of text and it would search for it. Now I have a requirement to add in dob to my search. I am not adding a new textbox with a dob picker. I just want users to be able to input a dob in a range of formats and it would figure it out. IE users can search using any combin...

What is the best way to sync computer time with an internet time server?

I need to get the current time from one of internet time server in my desktop application. I suppose I need something like a request string and a regular expression to get time from any site that user wants (may be with several predefined sites). Or may be there are some free libraries exist? Thanks. ...

How to get date representing the first day of a month?

I need functionality in a script that will enable me to insert dates into a table. What SQL do I need to insert a date of the format 01/08/2010 00:00:00 where the date is the first day of the current month. What do I need to change order that I can specify the month value? Thanks ...

TSQL function to find difference between two dates taking weekends and holidays into account

Tomalak posted an excellent response to an existing SO question: http://stackoverflow.com/questions/593898/sql-datediff-advanced-usage/594087#594087 It almost worked for me but I needed to compute the business hours difference between two dates, excluding weekends, even if less than a week had elapsed. My solution adds a while loop (w...

.NET DateTime not returning AM/PM in ToShortTimeString()

I've run into a problem that's driving me crazy. In my application (ASP.NET MVC2 /.NET4), I simply running this: DateTime.Now.ToShortTimeString() All the examples I've seen indicate I should get something like: 12:32 PM, however I'm getting 12:32 without the AM/PM. I launched LinqPad 4 to see if I could replicate this. Instead, it re...

Convert UTC time to phone local time

I am trying to get a local time from a server UTC time. I get the UTC time form the server -- and i want to make it right for each individual Android phone whether it be in California or China. This is the code I am using now -- however it snot working. The time I get from the server is "2010-08-17 19:41:13.0" And the code I use t...

How to make list with months and years from date in the past to the current month

I want to have dropdownlist with months and years from some point in the past to the current month. This is my code: for (int year = 2009; year <= DateTime.Now.Year; year++) { for (int month = 1; month <= 12; month++) { DateTime date = new DateTime(year, month, 1); this.MonthsCombo.Items.Add( new RadComboBoxI...

Procedure failed to run shows error: Conversion failed when converting date and/or time from character string

Hi, I have written a simple procedure: CREATE PROCEDURE [dbo].[sp_GetPublishedDocs2] @FromDate as Datetime AS BEGIN DECLARE @strSQL VARCHAR(5000) SET @strSQL='SELECT * From Task WHERE 1=1 ' IF @FromDate <>'1/1/1900' SET @strSQL = @strSQL + ' AND Task.CreatedDate >= '+Cast(@FromDate as Datetime) EXEC(@strSQL) END It run succe...

Convert ISO 8601-formatted time period to ticks / miliseconds

Is there a built-in way in .NET 3.5 to convert an ISO 8601 period into a .NET TimeSpan / ticks / miliseconds? ...

How to Convert String to DateTime in specified format ?

Hi string date="8/13/2010"; // mm/dd/yyyy System.Globalization.CultureInfo ci =System.Threading.Thread.CurrentThread.CurrentCulture; string CurrDateFormat = ci.DateTimeFormat.ShortDatePattern.ToString() -- **// dd/mm/yyyy** DateTime dt=Convert.ToDateTime(date); ***// Exception : In valid date time format*** date=dt.ToString(CurrDa...

Rails inconsistently fails to send datetime parameters

I am revising someone else's project which allows users to submit content either for either immediate or scheduled publication. There are a pair of radio buttons to select this, and a datetime field that is enabled by javascript if the radio button for 'scheduled' is selected <%= f.hidden_field :scheduled_state %> <%= f.radio_button :im...

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? ...

How to find the closest valid date to one given as an invalid date string

So there's this accounting package at my client that spits out text-based reports with invalid dates, like February 31st or September 31st. The reports are formatted with spaces and mono-spaced fonts. The data that gets parsed out are fed into a more formal local SSRS report, and that's about all you need to know. What I am interested ...

In a unix shell, how to get yesterday's date into a variable?

Hi, I've got a shell script which does the following to store the current day's date in a variable 'dt': date "+%a %d/%m/%Y" | read dt echo ${dt} How would i go about getting yesterdays date into a variable? Basically what i'm trying to achieve is to use grep to pull all of yesterday's lines from a log file, since each line in the lo...