ASP.Net Razor Days between dates - asp.net

I am working on a project and I need to calculate the days between date account created and current date. my code works how ever it is not giving me just the days. This below code
#(item.AccountCreated.AddYears(1)-DateTime.Now)
gives me this result like this 330.06:53:24.6752284 when all I want to be displayed would be 330 is there a way to do this through Razor.
Issue now resolved by doing
#Convert.ToInt32(((item.AccountCreated.AddYears(1)-DateTime.Now).TotalDays))

#((item.AccountCreated.AddYears(1)- DateTime.Now).TotalDays)

Related

Operation isnt valid due to current state

I know there are many tutorials but I cant connect them with my specific case, so i'd like if anyone could make it clear to me.
https://i.stack.imgur.com/zyNoE.png
https://i.stack.imgur.com/9uFcZ.png
when updating through my grid my date update is working great but somewhy when trying to update name ('שם') the error is thrown. thanks
edit** if u see comments // ull see one line the name is working fine but date isnt. and another one is the exact opposite.
another thing I found out is that if I update both name and date at the same time, I get no error..

Ionic 2 Date Pipe adds hour

I've got a webservice which provide my app from data.
Currently I've got issues with dates.
In my Ionic pages i use the date pipe like this:
{{model.DateStart | date: 'dd-MM-yyyy HH:mm'}}
This results in '18-02-2017 14:08', thats good.
But when the service sends this '2017-02-18T15:00:00' the result is '18-02-2017 16:00'.
That's not good.. It adds a hour somewhere.
It'll have to do with the locale settings somewhere, but I don't know how to fix it.
Anyone knows how to fix this problem?
After implementing moment.js I get the result I want.

FullCalendar call gotoDate and set firstDay programatically

I have added a custom button to the header of the calendar that has each month of the year in it. The idea is that you can select the month and the calendar will jump to that month.
I currently have firstDay set to 1 to start the calendar on a Monday, this is because in most scenarios I do want Monday to be the first day. When I call gotoDate I would like the calendar to jump to that date with it being the first visible day on the calendar; it should always be the 1st of the selected month.
Currently it goes to the date but the firstDay is Monday of that week.
I have searched to see if I could find anyone else trying to achieve this and came across the this issue but this was for quite an old version of FC, I am using 2.7
Is there a way to pragmatically set the firstDay without forking the calendar and changing the internal code?
Any help would be greatly appreciated.
*I haven't included any code because I don't think it would add any value to the question. I am not calling anything to set the firstDay other than when it is initialised.
I have found that as of version 2.9, released on the 11th July 2016 support has been added for getting and setting options dynamically.
I have upgraded from version 2.7 to 2.9 and managed to use the following code to set firstDay after the calendar is initialised.
$('#calendar').fullCalendar('option', 'firstDay', 0);
The documentation for Get/Set Options Dynamically, not all options can be set dynamically.
The GitHub issue that added the functionality.

How to get the correct LastModifiedDate from SPFile in SP2013

I've got a Issue with SharePoint 2013 Files in Libraries. If I push an File via WebDAV into an Folder the file will still hold it's created/modified date (and that's good!).
Other Case is: I use the "New Document" Upload Form - the File will be newly created and loses its correct created/modified date.
I'm looking for a way to get these correct Values of the SPFile Item.
DateTime modified = Li.File.TimeLastModified;
That's my current attempt to get the DateTime but it only retrieves the "sharepoint" value and not the "filesystem" value of the LastModifiedDate.
I tried to let my Webpart open the File on the server.. but URI-Formats arent supported :-(
Has anybody already run into this problem?
Thanks for your help in advance!
EDIT:
This is what I get in explorer view of the document library. For example the file lync.PNG has a last modified date of 26.12.2013.
this is what I get from my webpart using the code snippet (sorry for the german description; "geändert am" means lastmodifieddate)
You can get the modified date that SharePoint uses by getting the Item of the SPFile then reading the date property. Something like this:
DateTime date = DateTime.Parse(file.Item["Modified"].ToString());
Once its in SharePoint any changes should come from the modified property of the item. You would have to use an event receiver to capture the original file date and then overwrite the SharePoint created date, or add the value to another field in the item.
Hope this helps.

WP: Page Not Found

I am using WP-3.3.2 and had created a website eyepractice my script gets month and year from url and then shows calendar for that month and year but when I integrate with Wp it only work for year 2012 and if I use http://www.eyepractice.ca/optometris/guelph/?month=1&year=2013 it shows Page Not Found however I have already created a Page named guelph from Wp admin. I searched whole project for 2012 but it is not hard coded.
This is a REALLY old question, but I came across it while looking for solution to the exact same problem, so I will leave an answer here.
I used a calendar creation script based on this link:
http://davidwalsh.name/php-event-calendar
In Wordpress apparently using 'year' and 'month' as $_GET variables conflicts with Wordpress internal query variable handling, so the calendar only worked for current year for me and threw a 'page not found' error on the next year.
The solution was simple. As #janw suggested, change the parameter names. In the script wherever $_GET variable is called 'month' or 'year', change it to something else like 'cal_month' or 'cal_year'. Works like a charm.

Resources