datetime

Is there a function in c# which returns date&time when given GMT values(-12 to -1 and 1 to 12)?

Is there a function in c# which returns date&time when given GMT values(-12 to -1 and 1 to 12)? EDIT: I have a Dropdownlistbox which contains all GMT values.. Now i want to display date&time of a selected GMT value.... ...

Custom date format cannot be parsed. (Java)

I have to parse a custom date format in Java. It contains microseconds although Java doesn't provide support for microseconds. Because of that I filled the format with zeroes, but now I cannot parse date-strings with that format. Is there a simple workaround or must I handle microseconds on my own (with String functions)? @Test public ...

mssql_query() fields blank for datetime fields

Running php 5.2.5 on Windows Server 2003 (64 bit) and connecting to SQL Server 2008 Having issues getting datetime fields from SQL Server using mssql_query. Any datetime field that I query returns nothing. All other fields in the query are correct, but the datetime fields are blank. We switched from PEAR DB to mssql_ functions recentl...

C# list of past DateTimes

I have a method that returns the past x days and it currently does the following: var dates = new List<DateTime>(); for (int i = 0; i < numDays; i++) { dates.Add(DateTime.Today.AddDays(-i)); } return dates; I feel like there should be a more compact way of doing this, perhaps using LINQ. Suggestions? Also, if I do keep it the ...

SQL Query to aggregate DateDiff greater than given value

I have a logging table used for device “heartbeats”. I have these network devices that check-in/heartbeat with the server every 10 minutes. We are wanting statistics on when they miss their scheduled check-in time. I have a query that can do this on a per-device basis, but I need it to be modified to handle across all devices. The he...

Question on Converting ints to datetimes in TSQL

I have a stored procedure that takes an int for the desired month and year as parameters. It uses these to compare some datetime values from the tables I'm pulling from. I need to conver them into DateTime values. I'm trying to do something like this: CONVERT(DATETIME, CONVERT(varchar(4), @year) + '-' + Convert(varchar(2),@month) + '-01...

Enumerate a DateRange

I have 2 dates and I am trying to build labels of an x-axis of a plot. As such, I need a way to take 2 datetime objects, i.e 2009-10-12 00:00:00 and 2009-10-20 00:00:00 and generate a list like so: ["2009-10-12", "2009-10-13", "2009-10-14", ..., "2009-10-19", "2009-10-20"] What libraries should I use to assist? I have a feeling the ...

date convert and merge in php

I have two sets of information. One is a date that is in Tuesday, January 26, 2010 format. This is $date Now i also have one of two things for time. $stime can be either 7:30pm or Tuesday, January 26, 2010 7:30pm What i need to do, is first, convert $stime to HH:MM:SS format, then combine it with $date and convert the two together to ...

How to round to nearest X minutes with PL/pgSQL?

How I can round to nearest X minutes? Here's my attempt: DECLARE _stamp ALIAS FOR $1; -- timestamp _nearest ALIAS FOR $2; -- minutes (integer) _minutes decimal; _ret timestamp; BEGIN _ret := date_trunc('minute', _stamp); SELECT EXTRACT (minute FROM _ret)::integer INTO _minutes; IF (_minutes % _nearest < (_nearest / 2)) ...

Calculate week of month in .NET

Do the .NET libraries have an easy way of returning the week number for a given date? For example, input of Year = 2010, Month = 1, Day = 25, should output 5 for the week number. Closest I found was Calendar.GetWeekOfYear, which is almost there. Java has a date string format "W" which returns week in month but I can't see anything equi...

regist payment for each month of the year using oracle data

I have the following tables: Employees with level (rank or wtv you may call it): income_value,id, etc. INCOME that stores the rank vs. the income value (very tinny and static) REGIST_INCOME table with the following columns: ID_REG; ID_EMPLOYEE; MONTH_and_Year_OF_PAYMENT DATE (I want to format to yy.mm); DATE_OF_PAYMENT DATE ...

ActiveRecord model with datetime stamp with timezone support attribute.

Rails is great that it will support timezone overall in the application with Time.zone. I need to be able to support the timezone a user selects for a record. The user will be able to select date, time, and timezone for the record and I would like all calculations to be done with respect to the user selected timezone. My question is wha...

Format DateTime like StackoverFlow

Possible Duplicates: Fuzzy date algorithm How do I calculate relative time? Hi, How-to format datetime like SO ? 1 minute ago 1 hour ago asked Aug 15 at 15:00 ...

How to return my current time zone in RoR?

When I use return the time that the record created, it show this : 2010-01-20 15:04:40 UTC but I want the time in my specify time zone, for example, China. Is there any convenient method in RoR? ...

Convert datetime fields in Chrome history file (sqlite) to readable format

Working on a script to collect users browser history with time stamps ( educational setting). Firefox 3 history is kept in a sqlite file, and stamps are in UNIX epoch time... getting them and converting to readable format via a SQL command in python is pretty straightforward: sql_select = """ SELECT datetime(moz_historyvisits.visit_date...

C# DateTime.Now precision

I just ran into some unexpected behavior with DateTime.UtcNow while doing some unit tests. It appears that when you call DateTime.Now/UtcNow in rapid succession, it seems to give you back the same value for a longer-than-expected interval of time, rather than capturing more precise millisecond increments. I know there is a Stopwatch cl...

Is it better to use DateTime.MinValue or a nullable DateTime?

If I had a DateTime on a class called "TimeLastAccessed", would it make more sense for this DateTime to be nullable: public DateTime? TimeLastAccessed { get; set } if (TimeLastAccessed == null) // ... handle it to indicate it has never been accessed or check for DateTime.MinValue public DateTime TimeLastAccessed { get; set; } if (...

Need a formula: Extracting Years from Seconds Since January 1, 0001 12:00 AM

Input: # of seconds since January 1st, of Year 0001 Output: # of Full years during this time period I have developed an algorithm that I do not think is the optimal solution. I think there should be a solution that does not involve a loop. See Code Block 1 for the algorithm which A) Determines the quantity of days and B) Iteratively su...

How to create a function which can return Date Difference in javascript?

i have created below function to get date difference between two dates.. pleas check it that its correct as well as how to find no of month (multiply by 30 or 31 ?) and year.. function days_between(date1, date2,datepart) { // The number of milliseconds in one day var ONE_DAY=0; if ( datepart === undefined ) { datepart = 'D'; } i...

C# Adding a Time to a DateTime.

Hi all, I have a calendar and a textbox that contains a time of day. I want to create a datetime that is the combination of the two. I know i can do it by looking at the hours and mintues and then adding these to the calendar DateTime but this seems rather messy. Is there a better way? Thanks, Kohan. ...