datetime

How can I specify the latest time of day with DateTime

I am using a System.DateTime object to allow a user to select a date range. The user is only able to select a date (not time) using a third party calendar so I will need to automatically specify the time of day it should use (ie: 00:00:00 or 23:59:59) after the date is chosen. How can I specify the time after the date is already stored ...

How can I convert a .Net Datetime to a T-SQL Datetime

MyDataSource.SelectParameters["startDate"].DefaultValue = fromDate.SelectedDate.Date.ToString(); As you can see I am setting the default value of a parameter in my .Net SqlDataSource. I don't think the string is outputting the correct format though. What is the correct format so a T-SQL Datetime wil...

Based on a c# datetime, output the month as MM?

DUP: http://stackoverflow.com/questions/501460/format-date-in-c I have a datetime object (initialized), how can I output the month part as MM? ...

Linq to SQL DateTime values are local (Kind=Unspecified) - How do I make it UTC?

Isn't there a (simple) way to tell Linq To SQL classes that a particular DateTime property should be considered as UTC (i.e. having the Kind property of the DateTime type to be Utc by default), or is there a 'clean' workaround? The time zone on my app-server is not the same as the SQL 2005 Server (cannot change any), and none is UTC. Wh...

Java/Servlet: get current sql.Date

What I need to do is: 1) Get user's locale from request. 2) Create new sql.Date object with current date and time, based on user's locale 3) Write it in MySQL db, column type: TIMESTAMP What I got is: java.util.Locale locale = request.getLocale(); java.text.DateFormat dateFormat = java.text.DateFormat.getDateTimeInstance( ...

T-SQL: Round to nearest 15 minute interval

What's the best way to round a HH:MM value to the closest 15 minute interval? I don't track seconds so they don't matter. 00:08:00 becomes 00:15:00 00:07:00 becomes 00:00:00 01:59:00 becomes 02:00:00 and so on. Is there an elegant, non UDF or Case statement method for doing this? Thanks, James EDIT: Here's the SQL I'm using to ...

Where's the DateTime 'Z' format specifier?

[Update: Format specifiers are not the same thing as format strings; a format specifier is a piece of a custom format string, where a format string is 'stock' and doesn't provide customization. My problem is with specifiers not formats] I've been trying to perform roundtrip DateTime conversions with a format string that uses 'zzz' forma...

Why does getDay return incorrect values? (javascript)

I tried to get the day of a week with the getDay() function of the Date object in Javascript. In theory it works fine, but sometimes there is a delay in the output, so if the function should return a "4", it returns a "1". E.g. var date= new Date("2009","04","30"); alert(date.getDay()); // the function returns 6, should return 4 var ...

SQL Dynamic DatePart when using DateDiff

Is there a way to pass the DatePart parameter of DateDiff as a variable? So that I can write code that is similar to this? DECLARE @datePart VARCHAR(2) DECLARE @dateParameter INT SELECT @datePart = 'dd' SELECT @dateParameter = 28 SELECT * FROM MyTable WHERE DATEDIFF(@datePart, MyTable.MyDate, GETDATE()) < @dateParameter The only ...

validating between 2 textboxes - jquery

how i do validate two date textboxes using jquery. i came across this snippet of code. how do i enter the textbox parameters: $.validator.addMethod('greaterThan', function(value, element, param) { return ( IsNaN( value ) && IsNaN( $(param).val() ) ) || ( value > $(param).val() ); }, 'Must be greater than {0}.' ); $.validator.addMethod(...

Oracle - how to create date from an already existing date?

Say I issue: select date_field from table1; date_field is like '25.11.2009' I will try to change the positions of date fields with the month and vice versa. (of course for days > 12 some manipulations) TO_DATE( MOD(SUBSTR(TO_CHAR(a.A_DATE, 'DD.MM.YYYY'), 4, 2), 12) || '.' || SUBSTR(TO_CHAR(a.A_DATE, 'DD.MM.YYYY'), 1, 2...

Open Office Base Datetime Default

Can anyone tell me how to set the default value on a date field in Open Office Base, in the same way that GetDate() works for SQL Server? Cheers OneSHOT ...

I thought curtime(), now() and current_timestamp are valid default datetime values in MySql?

I'm using the latest version of MySql and I tried altering a table to use curtime() or now() or current_timestamp as the default value for a datetime column (created_at, updated_at). For all three, the alter failed, saying these are invalid default values. Any ideas what's an appropriate default value to generate the current time in a da...

call function between time intervals

In app engine I would like to call a function if the current time is between a particular interval. This is what I am doing now. ist_time = datetime.utcnow() + timedelta(hours=5, minutes = 30) ist_midnight = ist_time.replace(hour=0, minute=0, second=0, microsecond=0) market_open = ist_midnight + timedelta(hours=9, minutes = 55) market_...

How to find the next august? C#

I have the following problem: We need to find the next august. I other words if we are 2009-09-01 we need 2010-08-31 if we are 2009-06-21 we need 2009-08-31. I know I can check if today is smaller than august 31 but I was wondering if there is an other possibility. ...

Need to format dates in dynamically built WPF DataGrid.

We are binding an unknown result set to a WPF DataGrid at run time. Some of our columns are going to contain DateTime values and we need to properly format these date time fields. Without knowing which columns are going to be DateTime fields at design time, how are we able to format the columns at runtime? We are using a DataTable's D...

HTML/JSP Doubt, Print date on webpage...

I made a function which displays date on the webpage,, and i uploaded the same onto some server... But when i changed the date of my system, i noticed that the date is dependent on client machine.. Is it not possible to get the date from actual time server and embed that code into my program.. Hope i am able to explain my doubt.. Ple...

change date Time String to Sql server DateTime data type

how to change these Date Time strings to sql server DateTime Type: "Thu May 07 19:19:27" "Thu May 07 19:19:33" "Thu May 07 19:19:34" "Thu May 07 19:19:34" "Thu May 07 19:19:35" ...

Efficent way to set date using week of month value

I have a week of month in sql and i need to generate a datetime varible from that.. fields i have are dayofweek, weekofmonth and month values. anyone know of a quick effective way to calculate this in mssql 2005? Thanks Keep in mind. if week of month is set to 5 it is the last week of the month Examples are i have DayOfWeek, month, yea...

Backward-counting day display in php

I am a complete newbie in PHP. I would like to show the number of days missing for a specific date. In other words, I want to display something like: "X days to go for the great event" using PHP and the server time. How is this accomplished? ...