How to protect only Month and Year of a date in Powerbuilder so user can only edit day of the date?
As comments suggest, this reads more like a user requirement than a technical question (e.g. lack of mention of what type of control is involved), but if this were my requirement, I'd try one of these (user exercise to figure out which ones would actually work; it's not my requirement grin).
EditChanged: I'd put a date EditMask on a DataWindow (remember external DataWindows; it's a common misconception to think that controls on DataWindows have to be tied to a database column), and code the EditChanged to revert the year and month back to their set values if they've been changed. (I'd consider this pretty aggravating for the user, but it's possible)
Day field: Make the year and month StaticText, and make the day only an editable field. Edit, EditMask or EditMask with spin control would be appropriate for this (spin gives you control over the range with minimal scripting).
Custom control: Grab the source code for a dropdown calendar (PFC comes to mind), and customize it to disable the navigation between years and months.
Good luck,
Terry
Related
I have a site I'm doing where the owners wants to have a line in each bio: "Bill has been with us xx years". I don't want to have to go in at everyone's anniversary and change it. I know enough JS to break things, but I'm an advanced expert at copy and paste!! :-)
The client has given us the start month & year and we, obviously, know the current month and year. So I just need the code to do the calculation. I've looked at a whole mass of pages which seen to details this pretty well (if you know a bit of JS), but they all use a full date - MMDDYYYY - rather than just MMYYYY.
Upon logging into their accounts, each user has their login date and time stored to the database. What I was looking to do however is figure out the amount of days (or preferably convert into months if greater than a month) so that if a user views their profile they can see how active the band are. Also, this could benefit me in terms of keeping active profiles top of the agenda for content on the site so that it doesn't become stale from inactive users content filling up main page content.
I'm using ColdFusion so i'd be looking for a way to find for example how many days ago #lastLogin# was from #now()#. So say if the date of the last login was 23/04/2013 and todays date is 29/04/2013 it would read "Last Active, 1 day ago." However if the last login was 23/03/2013, it would read "Last Active, 1 month ago".
Anybody know how to do this? Thanks.
P.S I currently have no code from testing this as I have no idea where to start in terms of achieving this.
Use DateDiff
<cfset days = dateDiff("d", LoginDateVariable, now()) />
It's as simple as that.
P.S I currently have no code from testing this as I have no idea where
to start in terms of achieving this.
This doesn't answer your direct question but to help you know where to get started, I would strongly suggest reviewing the built in ColdFusion functions and tags that are available to you.
Tags
Tags by function
Functions
Functions by category
Also, Google searches usually land you at the docs, just add "coldfusion" to your search string. Searching google for coldfusion date functions yields very helpful answers, the first of which are a list of all ColdFusion date functions.
Dale's answer is spot on. But I would also suggest returning it as a variable with your query. Let the SQL server do the work. It's very efficient for those types of calculations. Not that CF can't do them well, too. But it's probably more appropriate for SQL to do that lifting. Especially if you're already returning the lastLogin date.
It would be similar to the CF solution:
SELECT ...., lastLogin, DATEDIFF(d, lastLogin, GETDATE()) AS LastLoginDays
FROM ....
WHERE ....
That would give you the number of days. You'd have to decide how you wanted to define a month if you wanted to break it out by month/day. That would get a bit more complex. You could write a SQL function that could be run on both dates and give you an accurate count of days/months/years since last login.
One other thing to keep in mind: Where are the dates being generated? When you insert loginDate into the database, are you doing a now() in CF before you insert it or are you doing a getDate() in SQL when you insert it? Again, I would let the database do your date logic, but you'd want to compare the two dates from the same source. For instance, if your loginDate was a database getDate() then you may not want to compare that to a CF now(). One goes by the datetime of the SQL server and the other goes by the datetime of the CF server. They could be different.
How do I show only a particular day of the week in gwt-datePicker ?
E.g
If I select January or any month of the year, I want to see only "Tuesdays" for that month.
Cheers
Prince
Short answer: With the default component you cannot.
I would recommend you to create your own widget. Remember that GWT doesn't have support for the Calendar Object, so you'll need to do your own calculations.
I had a similar requirement once where the datepicker popup needed to show the week number in an additional column. Since you cannot subclass/override all the necessary behaviour of the standard classes, there was nothing for it in the end but to rip out the source code and create a new implementation with minor changes.
As for date calculations, there is a port of joda time which you can import client-side. Quite a bit of overkill if you only need the day of the week, though.
http://code.google.com/p/gwt-time/
In my application I have to store data month wise and year wise. So for this, I have to store the data along with date into database.
My requirement is how to store in terms of date and how to retrieve data with group by month and year. In my app I am showing a table of years and months, based on selected month and year. I have to show the data in a dashboard.
My problem is in storing and retrieving date data types.
Use the following syntax
SELECT * FROM DATABASE WHERE REQUIREDDATEFIELD LIKE '%2011-01%';
2011 is supposed to be the year
01 is supposed to be the month
DATABASE is supposed to be your mysql database name
REQUIREDDATEFIELD is supposed to be the field you are hoping to sort from month and year.
like '%2011-01%' is supposed to be meaning, all the records containing 2011-01 in the given field. It could be in the beginning or the end or in the middle of a large text, so having % in both the beginning and end of the search criteria is a good habit.
You just select either for a specific month or year or month and year. Or if you want all, you use GROUP BY.
I know this answer is quite vague and generic, but that's because your question is vague. You probably need to be more specific. Explain not only what you want to do, but what you have tried, and in which way that didn't work.
the calendar offered by ExtJS is not very intuitive for entering a birthdate, is it possible to use three separate fields (year, month, day) connected to each other and submit to the server only one value which is a composition: YYYY-MM-DD?
Or is there any good way to get a nicer calendar for entering a birthdate in an intuitive way?
Thank you.
Why isn't the ExtJS Datepicker worth for entering birthdate? In which field do you think it isn't proper - year, month or day? Yes, it is not same as 3 drop down lists with year month and day, but it provides absolute usability with least amount of code to select a date.
To answer your question as asked, you can use an xtype of "hidden" to send the date formatted how you wish.
Using a common blur event on the three dropdowns or textboxes you choose, you check to see if all three have been filled in and pass simple validation. you then set the value of the hidden field based on the format that you choose from the 3 separate fields.