Search Results

Search found 12421 results on 497 pages for 'date arithmetic'.

Page 41/497 | < Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >

  • Convert date time value to expected with SimpleDateFormat

    - by Khoi Nguyen
    I have an issue with converting a date time value to expected one with SimpleDateFormat (java), my expected format is MM/yyyy, and I want to convert 2 values to only 1 format MM-yyyy for example 05-2012 yyyy-MM for example 2012-05 ouput is 05/2012. I implemented something look like following String expiry = "2012-01"; try { result = convertDateFormat(expiry, "MM-yyyy", expectedFormat); } catch (ParseException e) { try { result = convertDateFormat(expiry, "yyyy-MM", expectedFormat); } catch (ParseException e1) { e1.printStackTrace(); } e.printStackTrace(); } private String convertDateFormat(String date, String oPattern, String ePattern) throws ParseException { SimpleDateFormat normalFormat = new SimpleDateFormat(oPattern); Date d = normalFormat.parse(date); SimpleDateFormat cardFormat = new SimpleDateFormat(ePattern); return cardFormat.format(d); } Now, the return value is 6808, I don't know why. Kindly anyone help me on this case.

    Read the article

  • Proper way to format date from database using javascript/jquery

    - by Darcy
    Hi all, I am calling my database which contains a datetime datatype. The date looks like this: 2005-05-23 16:06:00.000 I would like to display this in a table when a user selects a certain item from a list. I call my controller action and return Json of all the times and put them in a table. The problem is the date is completely wrong. What is displayed is this: /Date(1255470180000)/ The date that is returned isn't even parsable (which I don't want to do anyway) so I can't even get the data if I wanted to. Any ideas?

    Read the article

  • Row Source - combo box, filtering what pops up in a combo box by date

    - by primus285
    so I have a combo box that I want to pop up when somebody wants to search by year. It will allow them to see in that combo box only results that happened in a certain year. so far I have something like SELECT DISTINCT Database_New.ASEC FROM Database_New WHERE (((Database_New.Date) >= DateValue('01/01/2001') AND (((Database_New.Date) <= DateValue('12/031/2001'))); or SELECT DISTINCT Database_New.ASEC FROM Database_New WHERE (((Database_New.Date) >= BETWEEN DateValue('01/01/2001') AND DateValue('12/31/2001’))); as you can see, the kicker is that I am already sorting the thing with SELECT DISTINCT under the ASEC field. But I want to filter it one more by year so a whole bunch of ASEC values that didnt happen in that year (and there are quite a few that happen rarely, or would onyl be associeted with one year) do not pop up as avalible. so far I get an error like "Syntax error in query expression '(((Database_New.Date) = DateValue('01/01/2001') AND (((Database_New.Date) <= DateValue('12/031/2001')))' and I am a VBA person, not quite as good at debuggin SQL. Is it something easy? or will it simply not work the way I have it set up.

    Read the article

  • Date format strings in .Net and Java

    - by mizipzor
    I have an application that runs on both C# .Net and Java. Two entirely separate but identical code bases. The problem Im having is formatting date and numbers. For example: A user running the .Net variant is inputting a date and a format string. The 26th of April 1986 is formatted 1986-04-26. The actual date, along with the format string, is serialized to an XML file. Later another user running the Java variant opens said XML file and looks at the date. I want them to look the same. Whats the best approach here? There doesnt seem to be a one-to-one mapping between Java and .Nets format strings. Should I limit the possible formats to a selection I know I can represent fully in both .Net and Java?

    Read the article

  • Jasper Reports - Add one day to a Date Parameter

    - by Templar
    I'm creating a Jasper report that includes the following parameters: DATESTART (Date) DATEEND (Date) These parameters indicate a date range for a field called DATECREATED (Timestamp) which includes times. I would like the date range to be INCLUSIVE, that is, if I filter for "Jan 1, 2009" to "Jan 31, 2009", any DATECREATED value on Jan 31, 2009 (such as "Jan 31, 2009 15:00") will be included in the report. When I used Crystal Reports in the past, I used the DATEADD function to create a filter expression like the following: {DATECREATED} >= {DATESTART} and {DATECREATED} < DATEADD("d", 1, {DATEEND}) (I realize that this isn't syntactically correct, but you get the idea.) Is there any way to do something similar in Jasper Reports?

    Read the article

  • CTE and last known date processing

    - by stackoverflowuser
    Input @StartDate = '01/25/2010' @EndDate = '02/06/2010' I have 2 CTEs in a stored procedure as follows: with CTE_A as ( [gives output A..Shown below] ), with CTE_B as ( Here, I want to check if @StartDate is NOT in output A then replace it with the last known date. In this case, since @startdate is less than any date in output A hence @StartDate will become 02/01/2010. Also to check if @EndDate is NOT in output A then replace it with the last known date. In this case, since @enddate is 02/06/2010 hence it will be replace with 02/05/2010. // Here there is a query using @startDate and @EndDate. ) output A Name Date A 02/01/2010 B 02/01/2010 C 02/05/2010 D 02/10/2010

    Read the article

  • ASP.NET MVC Posted date field comes in as 1/1/0001

    - by engil
    Just started working with .NET and MVC(1). I'm having a problem wherein in my add action the entered date for some reason ends up as 1/1/0001 instead of what is entered thus causing a date overflow. In my model, this field ("Added") is is of type datetime and does not allow nulls. In my controller I have: public ActionResult Add() { Instance instance = new Instance() { Added = DateTime.Now, Active = true }; return View(instance); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Add(Instance instance) { if (ModelState.IsValid) { try { System.Diagnostics.Trace.Write("test"); instanceRepository.Add(instance); instanceRepository.Save(); return RedirectToAction("Details", new { id = instance.InstanceID }); } catch { ModelState.AddRuleViolations(instance.GetRuleViolations()); } } return View(instance); } And in my view I have: <div class="editor-label"> <%= Html.LabelFor(model => model.Added) %> </div> <div class="editor-field"> <%= Html.TextBoxFor(model => model.Added,String.Format("{0:g}",Model.Added))%> <%= Html.ValidationMessageFor(model => model.Added) %> When I first go to Instances/Add the default value is set correctly, however as soon as I submit the date turns into 1/1/0001 (from my understanding this indicates that it was either null or in an unrecognizable format) When I debug and palce a watch on Request.Form I see the date coming in encoded ie Request.Form {Added=4%2f9%2f2010+8%3a24%3a39+AM} - is this an issue? I know its probably not enough information to make a conlusive determination on why this is failing, but if someone could provide some good debugging tips on how to determine where the submitted date is getting munged I'd really appreciate it.

    Read the article

  • PHP Date Manipulations

    - by Ajith
    I need to get previous 30 days from a specific date which is available from database(eg: 2010-05-23 12:36:29).I am try it by using date('d', strtotime("-30 days")) Which is getting the currect answer what i looking for but it is not help me to enter date from database.Please help me to solve the issue.

    Read the article

  • date picker in asp.net mvc

    - by Renu123
    i have basic date picker but i wank to add image as icon for date picker i have done it with the helper but now how can provide selecting year facility to the user if he want to select year 1986 then how much time he want to click so i want to add selecting year facility with icon date picker. if any one konws please tell me thanks in advance.

    Read the article

  • Using MySQL to generate daily sales reports with filled gaps, grouped by currency

    - by Shane O'Grady
    I'm trying to create what I think is a relatively basic report for an online store, using MySQL 5.1.45 The store can receive payment in multiple currencies. I have created some sample tables with data and am trying to generate a straightforward tabular result set grouped by date and currency so that I can graph these figures. I want to see each currency that is available per date, with a 0 in the result if there were no sales in that currency for that day. If I can get that to work I want to do the same but also grouped by product id. In the sample data I have provided there are only 3 currencies and 2 product ids, but in practice there can be any number of each. I can correctly group by date, but then when I add a grouping by currency my query does not return what I want. I based my work off this article. My reporting query, grouped only by date: SELECT calendar.datefield AS date, IFNULL(SUM(orders.order_value),0) AS total_value FROM orders RIGHT JOIN calendar ON (DATE(orders.order_date) = calendar.datefield) WHERE (calendar.datefield BETWEEN (SELECT MIN(DATE(order_date)) FROM orders) AND (SELECT MAX(DATE(order_date)) FROM orders)) GROUP BY date Now grouped by date and currency: SELECT calendar.datefield AS date, orders.currency_id, IFNULL(SUM(orders.order_value),0) AS total_value FROM orders RIGHT JOIN calendar ON (DATE(orders.order_date) = calendar.datefield) WHERE (calendar.datefield BETWEEN (SELECT MIN(DATE(order_date)) FROM orders) AND (SELECT MAX(DATE(order_date)) FROM orders)) GROUP BY date, orders.currency_id The results I am getting (grouped by date and currency): +------------+-------------+-------------+ | date | currency_id | total_value | +------------+-------------+-------------+ | 2009-08-15 | 3 | 81.94 | | 2009-08-15 | 45 | 25.00 | | 2009-08-15 | 49 | 122.60 | | 2009-08-16 | NULL | 0.00 | | 2009-08-17 | 45 | 25.00 | | 2009-08-17 | 49 | 122.60 | | 2009-08-18 | 3 | 81.94 | | 2009-08-18 | 49 | 245.20 | +------------+-------------+-------------+ The results I want: +------------+-------------+-------------+ | date | currency_id | total_value | +------------+-------------+-------------+ | 2009-08-15 | 3 | 81.94 | | 2009-08-15 | 45 | 25.00 | | 2009-08-15 | 49 | 122.60 | | 2009-08-16 | 3 | 0.00 | | 2009-08-16 | 45 | 0.00 | | 2009-08-16 | 49 | 0.00 | | 2009-08-17 | 3 | 0.00 | | 2009-08-17 | 45 | 25.00 | | 2009-08-17 | 49 | 122.60 | | 2009-08-18 | 3 | 81.94 | | 2009-08-18 | 45 | 0.00 | | 2009-08-18 | 49 | 245.20 | +------------+-------------+-------------+ The schema and data I am using in my tests: CREATE TABLE orders ( id INT PRIMARY KEY AUTO_INCREMENT, order_date DATETIME, order_id INT, product_id INT, currency_id INT, order_value DECIMAL(9,2), customer_id INT ); INSERT INTO orders (order_date, order_id, product_id, currency_id, order_value, customer_id) VALUES ('2009-08-15 10:20:20', '123', '1', '45', '12.50', '322'), ('2009-08-15 12:30:20', '124', '1', '49', '122.60', '400'), ('2009-08-15 13:41:20', '125', '1', '3', '40.97', '324'), ('2009-08-15 10:20:20', '126', '2', '45', '12.50', '345'), ('2009-08-15 13:41:20', '131', '2', '3', '40.97', '756'), ('2009-08-17 10:20:20', '3234', '1', '45', '12.50', '1322'), ('2009-08-17 10:20:20', '4642', '2', '45', '12.50', '1345'), ('2009-08-17 12:30:20', '23', '2', '49', '122.60', '3142'), ('2009-08-18 12:30:20', '2131', '1', '49', '122.60', '4700'), ('2009-08-18 13:41:20', '4568', '1', '3', '40.97', '3274'), ('2009-08-18 12:30:20', '956', '2', '49', '122.60', '3542'), ('2009-08-18 13:41:20', '443', '2', '3', '40.97', '7556'); CREATE TABLE currency ( id INT PRIMARY KEY, name VARCHAR(255) ); INSERT INTO currency (id, name) VALUES (3, 'Euro'), (45, 'US Dollar'), (49, 'CA Dollar'); CREATE TABLE calendar (datefield DATE); DELIMITER | CREATE PROCEDURE fill_calendar(start_date DATE, end_date DATE) BEGIN DECLARE crt_date DATE; SET crt_date=start_date; WHILE crt_date < end_date DO INSERT INTO calendar VALUES(crt_date); SET crt_date = ADDDATE(crt_date, INTERVAL 1 DAY); END WHILE; END | DELIMITER ; CALL fill_calendar('2008-01-01', '2011-12-31');

    Read the article

  • Calculate Age, Given Date of Birth

    - by bond
    Given a date of birth, how would I go about calculating an age in C? For example, if today's date is 20/04/2010 and the date of birth given is 12/08/86, then age will be 23 years, 8 months, and 8 days. Any suggestions would be appreciated. Thanks!

    Read the article

  • Optimal way to convert to date

    - by IMHO
    I have legacy system where all date fields are maintained in YMD format. Example: 20101123 this is date: 11/23/2010 I'm looking for most optimal way to convert from number to date field. Here is what I came up with: declare @ymd int set @ymd = 20101122 select @ymd, convert(datetime, cast(@ymd as varchar(100)), 112) This is pretty good solution but I'm wandering if someone has better way doing it

    Read the article

  • Convert date to string upon saving a doctrine record

    - by takteek
    Hi, I'm trying to migrate one of my PHP projects to Doctrine. I've never used it before so there are a few things I don't understand. In my current code, I have a class similar to this: class ScheduleItem { private Date start; //A PEAR Date object. private Date end; public function getStart() { return $this-start; } public function setStart($val) { $this-start = $val; } public function getEnd() { return $this-end; } public function setEnd($val) { $this-end= $val; } } I have a ScheduleItemDAO class with methods like save(), getByID(), etc. When loading from and saving to the database, the DAO class converts the Date objects to and from strings so they can be stored in a timestamp field. In my attempt to move to Doctrine, I created a new class like this: class ScheduleItem extends Doctrine_Record { public function setTableDefinition() { $this-hasColumn('start', 'timestamp'); $this-hasColumn('end', 'timestamp'); } } I had hoped I would be able to use Date objects for the start and end times, and have them converted to strings when they are saved to the database. How can I accomplish this?

    Read the article

  • Django Date Input Parsing?

    - by Dane Larsen
    I'm trying to get a date for an event from a user. The input is just a simple html text input. My main problem is that I don't know how to parse the date. If I try to pass the raw string, I get a TypeError, as expected. Does Django have any date-parsing modules?

    Read the article

  • Macro to copy data from one sheet to another based on the current date

    - by SgtSnafu
    Does anyone have a macro that copy data from one sheet to another based on the current date? I am working with a single workbook of three sheets. Sheet one will hold the manual input of daily production figures for multiple plants, sheet two is to hold ongoing daily data, keyed on sheet one. The macro will be associated with a button, so that once clicked it would search for every row that has a date of today, and copy that row to the next available blank row on sheet two. Sample Data... Plant 1 Input Date - $ Produced - Labor Hour 3-29-10 - 4538 - 8 3-30-10 - 7862 - 12 3-31-10 4-1-10 4-2-10 Plant 2 Input Date - $ Produced - Labor Hour 3-29-10 - 4545 - 9 3-30-10 - 7645 - 12 3-31-10 4-1-10 4-2-10

    Read the article

  • How to find browser date time format

    - by Ranjeet
    Hi All, I have date as 31.03.2010 in german ofcourse 31 is date,03 is month and 2010 is year. Now I want to display the date as per the selected datetime format for the browser, say is user has german for him I would display 31.03.2010 whereas for English I would display 03/31/2010. Any Idea how this can be done?

    Read the article

  • reverse loop for date display

    - by Michael
    Hi, I've been trying to figure this out, and can't seem to get it Here is the code.. $m= date("m"); $de= date("d"); $y= date("Y"); for($i=0; $i<=6; $i++){ echo "<br>"; echo date('m/d',mktime(0,0,0,$m,($de+$i),$y)); echo "<br>"; } That displays this 04/08 04/07 04/06 04/05 04/04 04/03 04/02 That is exactly what I want but I want it to flip around so echos it would like this 04/02 04/03 04/04 04/05 04/06 04/07 04/07 How would I do this? Thank you in advance!

    Read the article

  • Using DataTypeAttribute to validate a date

    - by Andy Evans
    I'm having some difficulty understanding how to validate a date (DOB) using MVC2. What I want to do is 1. Is the date entered a valid date and, 2. Is the date at lease 13 years in the past. For example, to validate an email I use the following code: [Required(ErrorMessage = "Email address is required.")] [StringLength(320, ErrorMessage = "Email must be less than 320 characters.")] [Email(ErrorMessage = "This email address is invalid.")] public string email { get; set; } To validate the email I use: public class EmailAttribute : RegularExpressionAttribute { public EmailAttribute() : base("insert long regex expression here") { } } Any assistance would be greatly appreciated, thanks!

    Read the article

  • How to change format of date/time?

    - by 4thSpace
    I have this date and time format: 2010-05-19 07:53:30 and would like to change it to: Wednesday @ 7:53PM 5/19/2010 I'm doing this, which gets the current format: NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss"; but when I change the format, I end up with a null. For example: formatter.dateFormat = @"hh:mm tt MM-dd-yyyy"; date = [formatter stringFromDate:formattedDate]; date will be null. I want to put the end result into an NSString. It would be nice if time and date could come out as separate properties so I can arrange them however I like. Any ideas on how I can change the formatting?

    Read the article

  • Comparing date in access database

    - by Simon
    How can i compare the day in the access database to a given day in c#? The date column in the database is an general date(day/month/year) try { database = new OleDbConnection(connectionString); database.Open(); date = DateTime.Now.ToShortDateString(); string queryString = "SELECT user_name,zivila.naziv " + "FROM (users LEFT JOIN obroki_save ON obroki_save.ID_uporabnika=users.ID)" + " LEFT JOIN zivila ON zivila.ID=obroki_save.ID_zivila " + " WHERE users.ID= " + a.ToString() + " AND obroki_save.datum=# " + date; loadDataGrid(queryString); } catch (Exception ex) { MessageBox.Show(ex.Message); return; }

    Read the article

  • What is the best way to findout whether a date falls in particular range?

    - by Amit
    I tried the following DateTime start = Convert.ToDateTime(TextBox1.Text); DateTime end = Convert.ToDateTime(TextBox2.Text); if (DateTime.Now.Date == start.Date || DateTime.Now.Date == end.Date || (DateTime.Now >= start.Date && DateTime.Now <= end.Date)) { lblResult.Text = "true"; } else { lblResult.Text = "false"; } This verifies if the date range is one day also. Any way to reduce the number of conditions above?

    Read the article

  • DDSteps date question.

    - by Srini
    DDStep Date Question: Currently trying to pass just the date from excel. But getting the below error while doing it. Failed to convert property value of type [java.lang.String] to required type [java.util.Date] for property ...no matching editors or conversion strategy found spring for date conversion I even tried to add customEditorConfigurer in the ddsteps-context file. Still getting error. But in their pet store example looks like it works fine. Any help is appreciated. <entry key="java.util.Date"> <bean class="org.springframework.beans.propertyeditors.CustomDateEditor"> <constructor-arg> <bean class="java.text.SimpleDateFormat"> <constructor-arg value="yyyy-MM-dd" /> </bean> </constructor-arg> <constructor-arg value="false" /> </bean> </entry>

    Read the article

  • MSSQL - select date field in table

    - by thegunner
    Hi, In my table I have a date column which the date is displayed in the format "2009-11-18 10:55:28.370" How can just get the date value of this field in a select statement. e.g. select id from risks, where creation_date = getdate()

    Read the article

  • Date Input in safari

    - by Fresheyeball
    So I am using the HTML5 date input type, primary to trigger the 'wheels' in iOS. Everything is working fine in ie7-9 Chrome and FF. But Safari for OSX is very upset. It sees the need to add little 'up and down' buttons to the right hand side and generally mess up my visual stylings. My attempt to fix this, is to change the date inputs back to text inputs for desktop browsers, and leave it as date inputs for mobile: unless device.is # 'device' is a lib I use to detect mobile browsers dateFields = $ 'input[type="date"]' dateFields.attr 'type', 'text' #this fails dateFields.datepicker() dateFields.on 'keyup', (e) -> e.preventDefault() $(@).val '' Beyond altering the input type with js, I am at a loss for how to fix this little bugger. Have you had to deal with this problem?

    Read the article

  • Drupal Exposed Views Filter custom date

    - by Jack
    I have a date filter that I have exposed on my view. I want to make the interface more user friendly and tighten up the look of it. Instead of selecting a date I would like to select from the following options. The last day The last week The last year All This would then filter on the date field. Is this possible? How would you go about doing this?

    Read the article

< Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >