w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Datetime.ParseExact is not working
Because April 27th, 2013 fell on a Saturday, not on a Sunday. If you try to parse Sat 27 Apr 2013 7:30pm It should work. You can see that by printing out the date using the same format, and comparing it with what you're trying to parse. bool dateParsed = false; DateTime date; CultureInfo provider = CultureInfo.InvariantCulture; string when = "Sat 27 Apr 2013 7:30pm"; dateParsed = DateTime.TryParseExact(when, "ddd d MMM yyyy h:mmtt", provider, DateTimeStyles.AssumeLocal, out date); Console.WriteLine(date); date = new DateTime(2013, 4, 27, 19, 30, 00, DateTimeKind.Local); Console.WriteLine(date.ToString("ddd d MMM yyyy h:mmtt", provider));

Categories : C#

String was not recognized as a valid DateTime in ParseExact
Apart from the fact that you're converting a DateTime to a string then back again, the DateTime format doesn't match exactly. DateTime.ParseExact parses a string into a DateTime object, and the format you provide it must match exactly. You said that DateTime.Now appears as 6/5/2013 2:29:21 PM, for which the correct format is M/d/yyyy h:mm:ss tt. Check MSDN for more information on custom date formats. I'm going to go out on a limb and say that, by looking at your code, I think you are trying to format the date into just the date, which can be achieved using the ToString method on DateTime: string todaysDate = DateTime.Now.ToString("MM/dd/yyyy"); // todaysDate will contain "06/05/2013"

Categories : Dotnet

vb.net datetime.parseExact error message saying invalid format
The error is because the seconds must be lower case. Also, you're asking for the month twice. I suspect this is the format string you need: yyyy.MM.dd-HH:mm:ss Just as an informational bit, the upper case 'H' means it's looking for 24-hour time, instead of 12-hour time. Lower-case 'h' would mean 12-hour time. Here is the reference for custom datetime format string rules: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

Categories : Vb.Net

Powershell ParseExact() Military time Convert-DateTime
Make the format string yyyyMMddHHmmss. hh is for 12-hour format, HH for 24-hour format. See here.

Categories : Dotnet

Date and time conversion in C# - DateTime.ParseExact() not working as expected
From msdn: If format is a custom format pattern that does not include date or time separators (such as "yyyyMMdd HHmm"), use the invariant culture for the provider parameter and the widest form of each custom format specifier. For example, if you want to specify hours in the format pattern, specify the wider form, "HH", instead of the narrower form, "H". so you can try: string input = "1-Mar-13 92330"; var date = DateTime.ParseExact(input, "d-MMM-yy Hmmss", System.Globalization.CultureInfo.InvariantCulture);

Categories : C#

strtotime and DateTime giving wrong year when parsing a year
EDIT: different formats... try $date = '2012-11'; $parts = explode('-', $date); switch(count($parts)){ case 2: $format = 'Y-m'; break; case 3: $format = 'Y-m-d'; break; case 1: default: $format = 'Y'; break; } $date = DateTime::CreateFromFormat($format, $year); echo $date->format('Y');

Categories : PHP

Create a Date class with fields day, month and year. (You cannot use the built-in DateTime class from .NET Library)
You want to make your own class myDateTime that has ints Day, Month, Year. Then you'll want to make a while(userinput != 0) loop where your program begins. When you receive input, you'll want to validate each integer, and then, if the data is valid, create an instance of myDateTime with the values. An example for data validation: if(userInputDay >= 1 && userInputDay <= 31 ) myDateTime.Day = userInputDay; From your code: if (value <= 30) Day = value; else if (value == 31) Day = value; else if (value == 28) Day = value; Is the same logic as: if(value <= 31) Day = value; Here's a start for you, it's pretty dumb and doesn't do any error checking but it's a start class Program { static void Main(string[] args) { Console.WriteLine("Input Month

Categories : C#

How to remove year from datetime object?
Use the standard ToString date formatter, with capital MM meaning "month month" and lower-case dd "day day" row.Cells[2].Text = dt.ToString("MM/dd");

Categories : C#

how make a datetime object in year 0 with python
from the docs The datetime module exports the following constants: datetime.MINYEAR The smallest year number allowed in a date or datetime object. MINYEAR is 1. datetime.MAXYEAR The largest year number allowed in a date or datetime object. MAXYEAR is 9999.

Categories : Python

MySQL Where Date (not datetime) as Week of year
Found a solution using WHERE IN() and generating an array of dates for current week. public function findCounter() { $now = new DateTime(); $semana = $now->format('Y-m-d'); $query = $this->getEntityManager() ->createQuery(" SELECT i FROM PgeIncidenciasBundle:Incidencia i WHERE i.fechaInicio IN (:semana) ") ->setParameters(array( 'semana' => $this->week_from_monday($semana) )) ; try { return $query->getResult(); } catch (DoctrineORMNoResultException $e) { return null; } } private function week_from_monday($date) { list($year, $month, $day) = explode("-", $date);

Categories : PHP

Feasible to specify only year on Python's datetime module?
datetime.date requires all three components: year, month and day. So you cannot skip any of them. If you need so special bahaviour define your own date class and use it appropriately.

Categories : Python

Compare SQL server datetime column to year month?
You could declare variables: DECLARE @YEAR AS INT DECLARE @MONTH AS INT SET @YEAR = 2012 SET @MONTH = 3 SELECT * FROM TABLE WHERE YEAR(MDTFlgtStart)=@YEAR AND MONTH(MDTFlgtStart)=@MONTH You can wrap the above in a procedure for re-usability....

Categories : Sql Server

compare list type year's value with datetime column in linq to sql query
I'll take a stab at this and recon you need something along the lines of: from d in context.tbl_pl_data where (d.lng_clientid.Equals(ClientId) && d.str_name.Equals(name) && d.int_deleted.Equals(0) && d.dte_cr_on.Year.Contains(Session["UserYearSelected"]) If there's multiple years however, you'll probably need to convert Session["UserYearSelected"] into a string[] Obviously can't test your query or check it compiles but hopefully it'll help you. You can also have a look at this for further help.

Categories : Linq

LNK 2019 and 2001 errors
You should check the 'BankingSystem.h' and the Account class in that. There error means these function address such 'getBalance' havn't found by compiler, so you should check these function exist or not first, then you must ensure the BankingSystem.lib file had been included in your project.

Categories : C++

Issue importing functions from DLL C++. LNK 2001
After some discussion in Chat, it turns out there are two parts to the solution of this problem: Need to use the stub library from the DLL class. Need to use class __declspec(dllexport) XClass to ensure the functionality from the class is exported.

Categories : C++

Error 2001 when using simplexml_loadfile to send XML
According to RFC 5730, 2001 - Command syntax error This response code MUST be returned when a server receives an improperly formed command element. It means your XML isn't valid. If you take a closer took, you can see that your opening tag doesn't match the closing tag in the following line: <pw>XXXXpw> ^ Change that to: <pw>XXXX</pw> and you should be fine. UPDATE: It seems this is occuring when you use simplexml_load_file which interprets the XML file as an object. It seems to me like the server needs raw XML as the input, and with simplexml_load_file you're sending an object. To fix this issue, you can just file_get_contents to get the contents of your XML file, and then send it as you normally would. Note that this may not be the bes

Categories : PHP

How to select every year from a particular year to the current year as different rows?
The easiest thing for you to do would be to create a numbers table that you would use for these types of queries. You could also use a recursive Common Table Expression to generate the list of years: ;with cte (yr) as ( select 2000 union all select yr + 1 from cte where yr+1 <=2013 ) select yr from cte; See SQL Fiddle with Demo

Categories : Sql Server

Java method calculate("2.002*1000") //returns 2001.999999999999
This is a textbook case of floating point mathematics. What you multipled wasn't actually 2.002 * 1000. instead, it was a number reeeeeeeeally close to 2.002 multiplied by a number reeeeeeeeally close to 1000. If you need absolute precision, you should use something java's BigDecimal type. In C#, you would use the decimal type. http://en.wikipedia.org/wiki/Round-off_error http://en.wikipedia.org/wiki/Floating_point

Categories : Java

QuickBooks API request returning "Premature end of file", error code -2001
Can you please try this call using ApiExplorer tool(QBD). Link - https://developer.intuit.com/apiexplorer?apiname=V2QBD PFB snapshot Please let me know if it works for you. EDIT Adding endpoint and post body. It worked fine Endpoint - https://services.intuit.com/sb/customer/v2/<relam-id> Content-Type: text/xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <CustomerQuery xmlns="http://www.intuit.com/sb/cdm/v2"> <FirstLastInside>Manas</FirstLastInside> </CustomerQuery>

Categories : Xml

How to create a trigger to find first day of the year?
You need to change the delimiter. MySQL sees the first ; as the end of the CREATE TRIGGER statement, and thinks the whole statement ends there. So you have to change the delimiter like this: /* Change the delimiter */ DELIMITER $$ CREATE TRIGGER upd_check BEFORE INSERT ON ColdStorage.ReservationDetails FOR EACH ROW BEGIN IF NEW.creationdate = DATE_FORMAT(NOW() ,'%Y-01-01') then insert into master_ids values ('0','0','0','0'); END if; END$$ /* the CREATE TRIGGER statement ends with new delimiter */ /* change the delimiter back to ; */ DELIMITER ; I haven't tested it, but it seems fine. What bothers me is that this will work just for one day during the year, the other 364 (365) days it is completely useless, and looks like an overhead.

Categories : Mysql

Create a mysql date from month and year
I'm not entirely sure what you;re asking but I think this is what you're looking for. $dt = DateTime::createFromFormat('Y-n', '2002-5'); echo $dt->format('Y-m-d H:i:s');

Categories : PHP

Date.parseExact doesn't give accurate result
You should be using M or MM Date.parseExact('01/13/2013', 'd/M/yyyy') Lowercase m is 'minutes', and since a month wasn't specified in your format string, the library defaulted to use the current month.

Categories : Javascript

Why method now in Python is obtained as datetime.datetime.now instead of datetime.time.now?
"Now" is a point in time. That means date matters; if it's noon now, yesterday noon is not also now. (Time of day also matters; 9 AM today is also not now.) Thus, it makes sense to have a datetime.datetime.now, but not a datetime.time.now. It could make sense to have a datetime.time.currentlocaltime or datetime.time.currentutctime, but those methods don't exist. You could put in a feature request if you want.

Categories : Python

PostgreSQL - show data of previous year + current year's week
Basic query for running sum Use the well-known aggregate function sum() as window function. SELECT week, x.last_year_profit + y.running_profit AS week_profit FROM ( -- total last year SELECT sum(profit) AS last_year_profit FROM sale_order WHERE date_order >= date_trunc('year', now() - interval '1 year') AND date_order < date_trunc('year', now()) ) x CROSS JOIN ( -- running sum current year SELECT date_trunc('week', date_order) AS week ,sum(sum(profit)) OVER (ORDER BY date_trunc('week', date_order)) AS running_profit FROM sale_order WHERE date_order >= date_trunc('year', now() - interval '1 year') AND date_order < date_trunc('year', now() + interval '1 year')

Categories : SQL

Regex for finding strings with reasonable "Year/YEAR" pattern
Description This expression will: match all your sample cases, while avoiding the undesired cases comply with a java regex engine Note this does use the x option which ignores whitespace and comments in the expression (?:^|s)(?:Year|YEAR)(?:s||$) # match no prefix or suffix | (?:^|s)[A-Z][a-z]+[^a-zA-Zd]?(?:Year|YEAR)(?:s||$) # match title case prefix | (?:^|s)[A-Z]+[^a-zA-Zds](?:Year|YEAR)(?:s||$) # match all uppercase prefix | (?:^|s)[a-z]+[^a-zA-Zd](?:year)(?:s||$) # match all lower case prefix and keyword | (?:^|s)(?:Year|YEAR)[^a-zA-Zd]?[A-Z][a-z]+(?:s||$) # match title case suffix | (?:^|s)(?:Year|YEAR)[^a-zA-Zds][A-Z]+(?:s||$) # match all uppercase suffix Or as a single string: (?:^|s)(?:Year|YEAR)(?:s||$)|(?:^|s)[A-Z][a-z]+[^a-zA-Zd]?(?:Year|YEAR)(?:s||$)|(?:^|

Categories : Regex

In R, how to select a year-specific datum from multiple year columns?
You could use a switch statement and a for loop: # Define a function to return which column the year refers to col_finder <- function(r1) { switch(r1, "2000"=1, "2001"=2, "2002"=3) } # Initiallize a new column x$yr.response2 <- NA # Switch statements are not vectorized, so run this in a for loop for(i in 1:nrow(x)) { cmn <- col_finder(as.character(x[i, "year"])) x[i, "yr.response2"] <- x[i, cmn] }

Categories : R

issue with NSDate I am removing year but takes 0001 as year
Its OKAY, since you are not using NSYearCalendarUnit in your following code NSInteger desiredComponents = (NSDayCalendarUnit | NSMonthCalendarUnit); so NSDate is assuming 0001 as default year, if you add NSYearCalendarUnit in the above code it will give correct year, like below NSInteger desiredComponents = (NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit);

Categories : IOS

MySQL: Convert year-by-year rows to columns?
...I see a technique for getting this done now, but I don't yet get why my technique failed. Any insight there?... You have to use an aggregate function (SUM(), MIN(), MAX() depending on your needs) and GROUP BY Try SELECT personid, SUM(CASE WHEN yearID = 1999 THEN event1 ELSE 0 END) event1_1999, SUM(CASE WHEN yearID = 2000 THEN event1 ELSE 0 END) event1_2000, SUM(CASE WHEN yearID = 2001 THEN event1 ELSE 0 END) event1_2001 FROM Table1 GROUP BY personid Same thing but with IF SELECT personid, SUM(IF(yearID = 1999, event1, 0)) event1_1999, SUM(IF(yearID = 2000, event1, 0)) event1_2000, SUM(IF(yearID = 2001, event1, 0)) event1_2001 FROM Table1 GROUP BY personid Output in both cases | PERSONID | EVENT1_1999 | EVENT1_2000 | EVENT1_20

Categories : Mysql

I need to select Year, AVG(score) where COUNT(id) is more than 1 grouped by year
Do you mean this? Select Year, AVG(score) FROM movies GROUP BY year HAVING count(*) > 1 ORDER BY year desc; The use of desc on group by is very MySQL specific. I think it is better to have an explicit order by.

Categories : SQL

Moment js create datetime in certain timezone
Assuming you are talking about moment-timezone, this does not currently exist in the 0.0.1 release, but has been requested. There is a pending pull request, but it has not yet been merged because there is still some lacking functionality. So you can go try adding that PR manually, or you can wait until it is stable. You might also consider using one of the other time zone libraries instead.

Categories : Javascript

jaxb how to reference an element to http://www.w3.org/2001/XMLSchema like
I'm working on the same problem today. I think you just need to fix your schemaLocation value: http://www.w3.org/2001/XMLSchema.xsd (tip - if you go to the location you have currently in the schemaLocation attribute, "http://www.w3.org/2001/XMLSchema", it directs you to the correct url)

Categories : Xml

CJuiDatePicker year/year-month/year-month-day selection
I would try to set all three Datepickers and hide()/show() them depending on your needs (with a dropdown or something like that..). You can also try to append() to the datepicker a bar menu with three buttons to switch between the modes. Good luck!

Categories : Javascript

How to create datetime object from "16SEP2012" in python
Use datetime.datetime.strptime: >>> datetime.datetime.strptime('16Sep2012', '%d%b%Y') datetime.datetime(2012, 9, 16, 0, 0)

Categories : Python

CakePHP 1.3 - create() not setting created datetime?
created DEFAULT NULL CakePHP will only populate created if it is defined as NULL: By defining a created and/or modified field in your database table as datetime fields (default null), CakePHP will recognize those fields and populate them automatically whenever a record is created ...

Categories : PHP

how to create datetime from a negative epoch in Python
This works for me: datetime.datetime(1970, 1, 1) + datetime.timedelta(seconds=(-3739996800000/1000)) → datetime.datetime(1851, 6, 27, 0, 0) This would have been better asked on StackOverflow since it is more Python specific than it is GIS-specific.

Categories : Python

create datetime irrespective of system date
The date/time is stored in a particular format regardless of the system locality. Only the the output is affected by the locality. Regardless of how it "looks" you can always change the output using the ToString method And the various formats You can even implement a global cultureinfo to apply which may be what you're looking for

Categories : C#

SQL Ranking Dates to Get Year Over Year Order
select T.YearMonth, rank() over (order by R.rnk asc, D.YearNumber desc) as [Rank], D.MonthNumber, D.YearNumber from Table1 as T outer apply ( select month(getdate()) as CurMonthNumber, cast(right(T.YearMonth, 2) as int) as MonthNumber, cast(left(T.YearMonth, 4) as int) as YearNumber ) as D outer apply ( select case when D.MonthNumber <= D.CurMonthNumber then D.CurMonthNumber - D.MonthNumber else 12 + D.CurMonthNumber - D.MonthNumber end as rnk ) as R sql fiddle example

Categories : SQL

Mysql Select events from last year but not this year
No joins required; just filter the orders when grouped on customer: SELECT CustomerID FROM Orders GROUP BY CustomerID HAVING SUM(OrderDate BETWEEN 2012-03-01 AND 2012-03-31) AND NOT SUM(OrderDate BETWEEN 2013-01-01 AND 2013-12-31)

Categories : PHP

python: create and update a datetime field in a sqlite db
Okay, I figured it out. You have to import time import datetime and then, rather than TempDateC = time.strptime(TempDateC, "%Y-%m-%dT%H:%M:%SZ") you need to parse the date with a few functions: TempDateC = datetime.datetime.fromtimestamp(time.mktime(time.strptime(TempdateC, "%Y-%m-%dT%H:%M:%SZ")))

Categories : Python

Create custom DateTime format respective of locality in .NET C#
System.Globalization.CultureInfo implements IFormatProvider, so you can provide a CultureInfo object as a parameter to the ToString method. MSDN seems to have an example of exactly what you want.

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.